1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 from os import F_OK, access, getcwd, path, sep
26 from numpy import array, asarray, exp, median, inf, log, save, std, sum, zeros
27 from minfx.generic import generic_minimise
28 from random import gauss
29 import re, math
30 from tempfile import mkdtemp, NamedTemporaryFile
31
32
33
34 from auto_analyses import relax_disp
35 from data_store import Relax_data_store; ds = Relax_data_store()
36 import dep_check
37 from lib.errors import RelaxError
38 from lib.io import get_file_path
39 from pipe_control.mol_res_spin import generate_spin_string, return_spin, spin_loop
40 from pipe_control.minimise import assemble_scaling_matrix
41 from specific_analyses.relax_disp.checks import check_missing_r1
42 from specific_analyses.relax_disp.estimate_r2eff import estimate_r2eff
43 from specific_analyses.relax_disp.data import average_intensity, check_intensity_errors, generate_r20_key, get_curve_type, has_exponential_exp_type, has_r1rho_exp_type, loop_exp_frq, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time, loop_time, return_grace_file_name_ini, return_param_key_from_data, spin_ids_to_containers
44 from specific_analyses.relax_disp.data import INTERPOLATE_DISP, INTERPOLATE_OFFSET, X_AXIS_DISP, X_AXIS_W_EFF, X_AXIS_THETA, Y_AXIS_R2_R1RHO, Y_AXIS_R2_EFF
45 from specific_analyses.relax_disp.model import models_info, nesting_param
46 from specific_analyses.relax_disp.parameters import linear_constraints
47 from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_LIST, EXP_TYPE_R1RHO, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, MODEL_IT99, MODEL_LIST_ANALYTIC_CPMG, MODEL_LIST_FULL, MODEL_LIST_NUMERIC_CPMG, MODEL_LM63, MODEL_M61, MODEL_M61B, MODEL_MP05, MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE, MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_PARAMS, MODEL_R2EFF, MODEL_TP02, MODEL_TAP03
48 from status import Status; status = Status()
49 from test_suite.system_tests.base_classes import SystemTestCase
50
51
52 if dep_check.C_module_exp_fn:
53 from specific_analyses.relax_fit.optimisation import func_wrapper, dfunc_wrapper, d2func_wrapper
54 from target_functions.relax_fit import jacobian, jacobian_chi2, setup
55
56 func = func_wrapper
57 dfunc = dfunc_wrapper
58 d2func = d2func_wrapper
59
60
62 """Class for testing various aspects specific to relaxation dispersion curve-fitting."""
63
64 - def __init__(self, methodName='runTest'):
65 """Skip certain tests if the C modules are non-functional.
66
67 @keyword methodName: The name of the test.
68 @type methodName: str
69 """
70
71
72 super(Relax_disp, self).__init__(methodName)
73
74
75 if not dep_check.C_module_exp_fn:
76
77 to_skip = [
78 "test_bug_atul_srivastava",
79 "test_bug_21344_sparse_time_spinlock_acquired_r1rho_fail_relax_disp",
80 "test_bug_9999_slow_r1rho_r2eff_error_with_mc",
81 "test_estimate_r2eff_err",
82 "test_estimate_r2eff_err_auto",
83 "test_estimate_r2eff_err_methods",
84 "test_finite_value",
85 "test_exp_fit",
86 "test_m61_exp_data_to_m61",
87 "test_r1rho_kjaergaard_auto",
88 "test_r1rho_kjaergaard_auto_check_graphs",
89 "test_r1rho_kjaergaard_man",
90 "test_r1rho_kjaergaard_missing_r1",
91 "test_value_write_calc_rotating_frame_params_auto_analysis"
92 ]
93
94
95 if methodName in to_skip:
96 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
97
98
99 if not dep_check.scipy_module:
100
101 to_skip = [
102 "test_estimate_r2eff_err_methods"
103 ]
104
105
106 if methodName in to_skip:
107 status.skipped_tests.append([methodName, 'scipy.optimize.leastsq module', self._skip_type])
108
109
111 """Set up for all the functional tests."""
112
113
114 self.interpreter.pipe.create('relax_disp', 'relax_disp')
115
116
117 ds.tmpdir = mkdtemp()
118 self.tmpdir = ds.tmpdir
119
120
122 """Setup data for the catch of U{bug #22146<https://gna.org/bugs/?22146>}, the failure of unpacking R2A and R2B, when performing a clustered full dispersion models.
123
124 @keyword folder: The name of the folder for the test data.
125 @type folder: str
126 @keyword model_analyse: The name of the model which will be tested.
127 @type model_analyse: str
128 """
129
130 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
131
132
133 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_22146_unpacking_r2a_r2b_cluster'+sep+folder
134
135
136
137 sfrq_1 = 500.0*1E6
138 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
139 time_T2_1 = 0.05
140 ncycs_1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 50]
141
142
143 r2eff_errs_1 = [0.0] * len(ncycs_1)
144 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
145
146 sfrq_2 = 600.0*1E6
147 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
148 time_T2_2 = 0.06
149 ncycs_2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
150
151
152 r2eff_errs_2 = [0.0] * len(ncycs_2)
153 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
154
155 sfrq_3 = 700.0*1E6
156 r20_key_3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_3)
157 time_T2_3 = 0.07
158 ncycs_3 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 50, 70]
159
160
161 r2eff_errs_3 = [0.0] * len(ncycs_3)
162 exp_3 = [sfrq_3, time_T2_3, ncycs_3, r2eff_errs_3]
163
164
165 exps = [exp_1, exp_2, exp_3]
166
167 R20 = [5.1, 5.2, 5.3, 10.1, 10.2, 10.3, 6.1, 6.2, 6.3, 11.1, 11.2, 11.3, 7.1, 7.2, 7.3, 12.1, 12.2, 12.3, 8.1, 8.2, 8.3, 13.1, 13.2, 13.3]
168 dw_arr = [1.0, 2.0, 3.0, 4.0]
169 pA_arr = [0.9]
170 kex_arr = [1000.]
171
172 spins = [
173 ['Ala', 1, 'N', {'r2a': {r20_key_1: R20[0], r20_key_2: R20[1], r20_key_3: R20[2]}, 'r2b': {r20_key_1: R20[3], r20_key_2: R20[4], r20_key_3: R20[5]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[0]}],
174 ['Ala', 2, 'N', {'r2a': {r20_key_1: R20[6], r20_key_2: R20[7], r20_key_3: R20[8]}, 'r2b': {r20_key_1: R20[9], r20_key_2: R20[10], r20_key_3: R20[11]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[1]}],
175 ['Ala', 3, 'N', {'r2a': {r20_key_1: R20[12], r20_key_2: R20[13], r20_key_3: R20[14]}, 'r2b': {r20_key_1: R20[15], r20_key_2: R20[16], r20_key_3: R20[17]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[2]}],
176 ['Ala', 4, 'N', {'r2a': {r20_key_1: R20[18], r20_key_2: R20[19], r20_key_3: R20[20]}, 'r2b': {r20_key_1: R20[21], r20_key_2: R20[22], r20_key_3: R20[23]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[3]}],
177 ]
178
179
180 pipe_name = 'base pipe'
181 pipe_type = 'relax_disp'
182 pipe_bundle = 'relax_disp'
183 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type, bundle = pipe_bundle)
184
185
186 for res_name, res_num, spin_name, params in spins:
187 self.interpreter.spin.create(res_name=res_name, res_num=res_num, spin_name=spin_name)
188
189
190 self.interpreter.spin.isotope('15N', spin_id='@N')
191
192
193 exp_ids = []
194 for exp_i in exps:
195 sfrq, time_T2, ncycs, r2eff_errs = exp_i
196 exp_id = 'CPMG_%3.1f' % (sfrq/1E6)
197 exp_ids.append(exp_id)
198
199 ids = []
200 for ncyc in ncycs:
201 nu_cpmg = ncyc / time_T2
202 cur_id = '%s_%.1f' % (exp_id, nu_cpmg)
203 ids.append(cur_id)
204
205
206 self.interpreter.spectrometer.frequency(id=cur_id, frq=sfrq)
207
208
209 self.interpreter.relax_disp.exp_type(spectrum_id=cur_id, exp_type=EXP_TYPE_CPMG_SQ)
210
211
212 self.interpreter.relax_disp.relax_time(spectrum_id=cur_id, time=time_T2)
213
214
215 self.interpreter.relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=nu_cpmg)
216
217 print("\n\nThe experiment IDs are %s." % cdp.spectrum_ids)
218
219
220
221
222 pipe_name_MODEL = "%s_%s"%(pipe_name, model_analyse)
223 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_MODEL, bundle_to = pipe_bundle)
224 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
225
226
227 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
228 exp_id = exp_ids[mi]
229 exp_i = exps[mi]
230 sfrq, time_T2, ncycs, r2eff_errs = exp_i
231
232
233 for res_name, res_num, spin_name, params in spins:
234 cur_spin_id = ":%i@%s"%(res_num, spin_name)
235
236
237 file_name = "%s%s.txt" % (exp_id, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
238
239
240 self.interpreter.relax_disp.r2eff_read_spin(id=exp_id, spin_id=cur_spin_id, file=file_name, dir=data_path, disp_point_col=1, data_col=2, error_col=3)
241
242
243 self.interpreter.relax_disp.select_model(model=model_analyse)
244
245
246 self.interpreter.relax_disp.cluster('model_cluster', ":1-100")
247
248
249 low_arr = R20 + dw_arr + pA_arr + kex_arr
250 self.interpreter.minimise.grid_search(lower=low_arr, upper=low_arr, inc=1, constraints=True, verbosity=1)
251
252
253 for i in range(len(spins)):
254 res_name, res_num, spin_name, params = spins[i]
255 cur_spin_id = ":%i@%s"%(res_num, spin_name)
256 cur_spin = return_spin(cur_spin_id)
257
258 for mo_param in cur_spin.params:
259 print(mo_param)
260
261 if isinstance(getattr(cur_spin, mo_param), dict):
262 for key, val in getattr(cur_spin, mo_param).items():
263 should_be = params[mo_param][key]
264 print(cur_spin.model, res_name, cur_spin_id, mo_param, key, float(val), should_be)
265 self.assertAlmostEqual(val, should_be)
266 else:
267 should_be = float(params[mo_param])
268 val = getattr(cur_spin, mo_param)
269 print(cur_spin.model, res_name, cur_spin_id, mo_param, val, should_be)
270 self.assertAlmostEqual(val, should_be)
271
272
273
274 self.assertAlmostEqual(cur_spin.chi2, 0.0, places = places)
275
276
278 """Set up the data for the test_r1rho_kjaergaard_*() system tests."""
279
280
281 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
282
283
284 ds.pipe_name = 'base pipe'
285 ds.pipe_bundle = 'relax_disp'
286 ds.pipe_type = 'relax_disp'
287
288
289 self.interpreter.pipe.create(pipe_name=ds.pipe_name, bundle=ds.pipe_bundle, pipe_type=ds.pipe_type)
290
291
292 self.interpreter.spectrum.read_spins(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
293
294
295 self.interpreter.spin.isotope(isotope='15N')
296
297
298 NR_exp = 70
299
300
301 expfile = open(data_path+sep+'exp_parameters_sort.txt', 'r')
302 expfileslines = expfile.readlines()[:NR_exp]
303 expfile.close()
304
305
306 yOBS = 81.050
307
308 yCAR = 118.078
309 centerPPM_N15 = yCAR
310
311
312 self.interpreter.chemical_shift.read(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
313
314
315 spin_lock_field_strengths_Hz = {'35': 431.0, '39': 651.2, '41': 800.5, '43': 984.0, '46': 1341.11, '48': 1648.5}
316
317
318
319 j = 0
320 for i in range(len(expfileslines)):
321 line = expfileslines[i]
322 if line[0] == "#":
323 continue
324 else:
325
326 DIRN = line.split()[0]
327 I = int(line.split()[1])
328 deltadof2 = line.split()[2]
329 dpwr2slock = line.split()[3]
330 ncyc = int(line.split()[4])
331 trim = float(line.split()[5])
332 ss = int(line.split()[6])
333 set_sfrq = float(line.split()[7])
334 apod_rmsd = float(line.split()[8])
335 spin_lock_field_strength = spin_lock_field_strengths_Hz[dpwr2slock]
336
337
338 time_sl = 2*ncyc*trim
339
340
341 FNAME = "%s_%s_%s_%s_max_standard.ser"%(I, deltadof2, dpwr2slock, ncyc)
342 sp_id = "%s_%s_%s_%s"%(I, deltadof2, dpwr2slock, ncyc)
343
344
345 self.interpreter.spectrum.read_intensities(file=FNAME, dir=data_path+sep+'peak_lists', spectrum_id=sp_id, int_method='height')
346
347
348 self.interpreter.spectrum.baseplane_rmsd(error=apod_rmsd, spectrum_id=sp_id)
349
350
351 self.interpreter.relax_disp.exp_type(spectrum_id=sp_id, exp_type='R1rho')
352
353
354 self.interpreter.relax_disp.spin_lock_field(spectrum_id=sp_id, field=spin_lock_field_strength)
355
356
357 frq_N15_Hz = yOBS * 1E6
358 offset_ppm_N15 = float(deltadof2) / frq_N15_Hz * 1E6
359 omega_rf_ppm = centerPPM_N15 + offset_ppm_N15
360
361
362 self.interpreter.relax_disp.spin_lock_offset(spectrum_id=sp_id, offset=omega_rf_ppm)
363
364
365 self.interpreter.relax_disp.relax_time(spectrum_id=sp_id, time=time_sl)
366
367
368 self.interpreter.spectrometer.frequency(id=sp_id, frq=set_sfrq, units='MHz')
369
370
371 j += 1
372
373
374 print("Testing the number of settings")
375 print("Number of settings iterations is: %s. Number of cdp.exp_type.keys() is: %s"%(i, len(cdp.exp_type.keys() ) ) )
376 self.assertEqual(70, len(expfileslines))
377 self.assertEqual(69, j)
378 self.assertEqual(69, len(cdp.exp_type.keys()) )
379
380
381 for curspin in cluster_ids:
382 print("Adding spin %s to cluster"%curspin)
383 self.interpreter.relax_disp.cluster('model_cluster', curspin)
384
385
386 for free_spin in cdp.clustering['free spins']:
387 print("Deselecting free spin %s"%free_spin)
388 self.interpreter.deselect.spin(spin_id=free_spin, change_all=False)
389
390
391
392
393
394 ds.ref = dict()
395 ds.ref[':13@N'] = [13, 'L13N-HN', 1.32394, 0.14687, 8.16007, 1.01237, 13193.82986, 2307.09152, 58703.06446, 22413.09854, 0.2261054135, 0.0863280812]
396 ds.ref[':15@N'] = [15, 'R15N-HN', 1.34428, 0.14056, 7.83256, 0.67559, 13193.82986, 2307.09152, 28688.33492, 13480.72253, 0.110498283, 0.051923428]
397 ds.ref[':16@N'] = [16, 'T16N-HN', 1.71514, 0.13651, 17.44216, 0.98583, 13193.82986, 2307.09152, 57356.77617, 21892.44205, 0.220919942, 0.084322679]
398 ds.ref[':25@N'] = [25, 'Q25N-HN', 1.82412, 0.15809, 9.09447, 2.09215, 13193.82986, 2307.09152, 143111.13431, 49535.80302, 0.5512182797, 0.1907960569]
399 ds.ref[':26@N'] = [26, 'Q26N-HN', 1.45746, 0.14127, 10.22801, 0.67116, 13193.82986, 2307.09152, 28187.06876, 13359.01615, 0.1085675662, 0.051454654]
400 ds.ref[':28@N'] = [28, 'Q28N-HN', 1.48095, 0.14231, 10.33552, 0.691, 13193.82986, 2307.09152, 30088.0686, 13920.25654, 0.1158896091, 0.0536163723]
401 ds.ref[':39@N'] = [39, 'L39N-HN', 1.46094, 0.14514, 8.02194, 0.84649, 13193.82986, 2307.09152, 44130.18538, 18104.55064, 0.1699753481, 0.0697329338]
402 ds.ref[':40@N'] = [40, 'M40N-HN', 1.21381, 0.14035, 12.19112, 0.81418, 13193.82986, 2307.09152, 41834.90493, 17319.92156, 0.1611346625, 0.0667107938]
403 ds.ref[':41@N'] = [41, 'A41N-HN', 1.29296, 0.14286, 9.29941, 0.66246, 13193.82986, 2307.09152, 26694.8921, 13080.66782, 0.1028201794, 0.0503825453]
404 ds.ref[':43@N'] = [43, 'F43N-HN', 1.33626, 0.14352, 12.73816, 1.17386, 13193.82986, 2307.09152, 70347.63797, 26648.30524, 0.2709565833, 0.1026407417]
405 ds.ref[':44@N'] = [44, 'I44N-HN', 1.28487, 0.1462, 12.70158, 1.52079, 13193.82986, 2307.09152, 95616.20461, 35307.79817, 0.3682830136, 0.1359943366]
406 ds.ref[':45@N'] = [45, 'K45N-HN', 1.59227, 0.14591, 9.54457, 0.95596, 13193.82986, 2307.09152, 53849.7826, 21009.89973, 0.2074121253, 0.0809234085]
407 ds.ref[':49@N'] = [49, 'A49N-HN', 1.38521, 0.14148, 4.44842, 0.88647, 13193.82986, 2307.09152, 40686.65286, 18501.20774, 0.1567119631, 0.07126073]
408 ds.ref[':52@N'] = [52, 'V52N-HN', 1.57531, 0.15042, 6.51945, 1.43418, 13193.82986, 2307.09152, 93499.92172, 33233.23039, 0.3601317693, 0.1280037656]
409 ds.ref[':53@N'] = [53, 'A53N-HN', 1.27214, 0.13823, 4.0705, 0.85485, 13193.82986, 2307.09152, 34856.18636, 17505.02393, 0.1342548725, 0.0674237488]
410
411 ds.guess = dict()
412 ds.guess[':13@N'] = [13, 'L13N-HN', 1.32394, 0.14687, 8.16007, 1.01237, 13193.82986, 2307.09152, 58703.06446, 22413.09854, 0.2261054135, 0.0863280812]
413 ds.guess[':15@N'] = [15, 'R15N-HN', 1.34428, 0.14056, 7.83256, 0.67559, 13193.82986, 2307.09152, 28688.33492, 13480.72253, 0.110498283, 0.051923428]
414 ds.guess[':16@N'] = [16, 'T16N-HN', 1.71514, 0.13651, 17.44216, 0.98583, 13193.82986, 2307.09152, 57356.77617, 21892.44205, 0.220919942, 0.084322679]
415 ds.guess[':25@N'] = [25, 'Q25N-HN', 1.82412, 0.15809, 9.09447, 2.09215, 13193.82986, 2307.09152, 143111.13431, 49535.80302, 0.5512182797, 0.1907960569]
416 ds.guess[':26@N'] = [26, 'Q26N-HN', 1.45746, 0.14127, 10.22801, 0.67116, 13193.82986, 2307.09152, 28187.06876, 13359.01615, 0.1085675662, 0.051454654]
417 ds.guess[':28@N'] = [28, 'Q28N-HN', 1.48095, 0.14231, 10.33552, 0.691, 13193.82986, 2307.09152, 30088.0686, 13920.25654, 0.1158896091, 0.0536163723]
418 ds.guess[':39@N'] = [39, 'L39N-HN', 1.46094, 0.14514, 8.02194, 0.84649, 13193.82986, 2307.09152, 44130.18538, 18104.55064, 0.1699753481, 0.0697329338]
419 ds.guess[':40@N'] = [40, 'M40N-HN', 1.21381, 0.14035, 12.19112, 0.81418, 13193.82986, 2307.09152, 41834.90493, 17319.92156, 0.1611346625, 0.0667107938]
420 ds.guess[':41@N'] = [41, 'A41N-HN', 1.29296, 0.14286, 9.29941, 0.66246, 13193.82986, 2307.09152, 26694.8921, 13080.66782, 0.1028201794, 0.0503825453]
421 ds.guess[':43@N'] = [43, 'F43N-HN', 1.33626, 0.14352, 12.73816, 1.17386, 13193.82986, 2307.09152, 70347.63797, 26648.30524, 0.2709565833, 0.1026407417]
422 ds.guess[':44@N'] = [44, 'I44N-HN', 1.28487, 0.1462, 12.70158, 1.52079, 13193.82986, 2307.09152, 95616.20461, 35307.79817, 0.3682830136, 0.1359943366]
423 ds.guess[':45@N'] = [45, 'K45N-HN', 1.59227, 0.14591, 9.54457, 0.95596, 13193.82986, 2307.09152, 53849.7826, 21009.89973, 0.2074121253, 0.0809234085]
424 ds.guess[':49@N'] = [49, 'A49N-HN', 1.38521, 0.14148, 4.44842, 0.88647, 13193.82986, 2307.09152, 40686.65286, 18501.20774, 0.1567119631, 0.07126073]
425 ds.guess[':52@N'] = [52, 'V52N-HN', 1.57531, 0.15042, 6.51945, 1.43418, 13193.82986, 2307.09152, 93499.92172, 33233.23039, 0.3601317693, 0.1280037656]
426 ds.guess[':53@N'] = [53, 'A53N-HN', 1.27214, 0.13823, 4.0705, 0.85485, 13193.82986, 2307.09152, 34856.18636, 17505.02393, 0.1342548725, 0.0674237488]
427
428
429 for spin, spin_id in spin_loop(return_id=True):
430 if spin_id in cluster_ids:
431 print("spin_id %s in cluster ids"%(spin_id))
432 spin.kex = ds.guess[spin_id][6]
433 spin.phi_ex = ds.guess[spin_id][10]
434 else:
435 print("spin_id %s NOT in cluster ids"%(spin_id))
436
437 if read_R1:
438
439 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
440
441
474
475
503
504
506 """Set up the data for the test_korzhnev_2005_data_*() system tests using the 'NS MMQ 2-site' model.
507
508 This loads the proton-heteronuclear SQ, ZQ, DQ, and MQ (MMQ) data from:
509
510 - Dmitry M. Korzhnev, Philipp Neudecker, Anthony Mittermaier, Vladislav Yu. Orekhov, and Lewis E. Kay (2005) Multiple-site exchange in proteins studied with a suite of six NMR relaxation dispersion experiments: An application to the folding of a Fyn SH3 domain mutant. 127, 15602-15611 (U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}).
511
512 It consists of the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
513
514
515 @keyword data_list: The list of data to load. It can contain 'SQ', '1H SQ', 'ZQ', 'DQ', 'MQ', and '1H MQ'.
516 @type data_list: list of str
517 """
518
519
520 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
521 self.interpreter.pipe.create(pipe_name='Korzhnev et al., 2005', pipe_type='relax_disp')
522
523
524 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
525 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
526 self.interpreter.spin.element('H', spin_id='@H')
527 self.interpreter.spin.element('N', spin_id='@N')
528 self.interpreter.spin.isotope('1H', spin_id='@H')
529 self.interpreter.spin.isotope('15N', spin_id='@N')
530
531
532 self.interpreter.interatom.define(spin_id1=':9@N', spin_id2=':9@H', direct_bond=True)
533
534
535 data = [
536 ['1H SQ', '1H_SQ_CPMG_500_MHz', 'hs_500.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 500e6, 0.03],
537 ['1H SQ', '1H_SQ_CPMG_600_MHz', 'hs_600.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 600e6, 0.03],
538 ['1H SQ', '1H_SQ_CPMG_800_MHz', 'hs_800.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 800e6, 0.03],
539 ['SQ', '15N_SQ_CPMG_500_MHz', 'ns_500.res', EXP_TYPE_CPMG_SQ, ':9@N', 500e6, 0.04],
540 ['SQ', '15N_SQ_CPMG_600_MHz', 'ns_600.res', EXP_TYPE_CPMG_SQ, ':9@N', 600e6, 0.04],
541 ['SQ', '15N_SQ_CPMG_800_MHz', 'ns_800.res', EXP_TYPE_CPMG_SQ, ':9@N', 800e6, 0.04],
542 ['DQ', '15N_DQ_CPMG_500_MHz', 'dq_500.res', EXP_TYPE_CPMG_DQ, ':9@N', 500e6, 0.03],
543 ['DQ', '15N_DQ_CPMG_600_MHz', 'dq_600.res', EXP_TYPE_CPMG_DQ, ':9@N', 600e6, 0.03],
544 ['DQ', '15N_DQ_CPMG_800_MHz', 'dq_800.res', EXP_TYPE_CPMG_DQ, ':9@N', 800e6, 0.03],
545 ['ZQ', '15N_ZQ_CPMG_500_MHz', 'zq_500.res', EXP_TYPE_CPMG_ZQ, ':9@N', 500e6, 0.03],
546 ['ZQ', '15N_ZQ_CPMG_600_MHz', 'zq_600.res', EXP_TYPE_CPMG_ZQ, ':9@N', 600e6, 0.03],
547 ['ZQ', '15N_ZQ_CPMG_800_MHz', 'zq_800.res', EXP_TYPE_CPMG_ZQ, ':9@N', 800e6, 0.03],
548 ['1H MQ', '1H_MQ_CPMG_500_MHz', 'hm_500.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 500e6, 0.02],
549 ['1H MQ', '1H_MQ_CPMG_600_MHz', 'hm_600.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 600e6, 0.02],
550 ['1H MQ', '1H_MQ_CPMG_800_MHz', 'hm_800.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 800e6, 0.02],
551 ['MQ', '15N_MQ_CPMG_500_MHz', 'nm_500.res', EXP_TYPE_CPMG_MQ, ':9@N', 500e6, 0.02],
552 ['MQ', '15N_MQ_CPMG_600_MHz', 'nm_600.res', EXP_TYPE_CPMG_MQ, ':9@N', 600e6, 0.02],
553 ['MQ', '15N_MQ_CPMG_800_MHz', 'nm_800.res', EXP_TYPE_CPMG_MQ, ':9@N', 800e6, 0.02]
554 ]
555 cpmg_frqs_1h_sq = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0]
556 cpmg_frqs_sq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
557 cpmg_frqs_dq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0]
558 cpmg_frqs_zq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0]
559 cpmg_frqs_1h_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 1000.0, 1500.0, 2000.0, 2500.0]
560 cpmg_frqs_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
561
562
563 for data_type, id, file, exp_type, spin_id, H_frq, relax_time in data:
564
565 if data_type not in data_list:
566 continue
567
568
569 if data_type == 'SQ':
570 cpmg_frqs = cpmg_frqs_sq
571 elif data_type == '1H SQ':
572 cpmg_frqs = cpmg_frqs_1h_sq
573 elif data_type == 'DQ':
574 cpmg_frqs = cpmg_frqs_dq
575 elif data_type == 'ZQ':
576 cpmg_frqs = cpmg_frqs_zq
577 elif data_type == '1H MQ':
578 cpmg_frqs = cpmg_frqs_1h_mq
579 elif data_type == 'MQ':
580 cpmg_frqs = cpmg_frqs_mq
581
582
583 for cpmg_frq in cpmg_frqs:
584
585 new_id = "%s_%s" % (id, cpmg_frq)
586
587
588 self.interpreter.spectrometer.frequency(id=new_id, frq=H_frq)
589
590
591 self.interpreter.relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type)
592
593
594 self.interpreter.relax_disp.relax_time(spectrum_id=new_id, time=relax_time)
595
596
597 self.interpreter.relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq)
598
599
600 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3)
601
602
603 self.interpreter.relax_disp.select_model('NS MMQ 2-site')
604
605
606 - def setup_sod1wt_t25(self, pipe_name, pipe_type, pipe_name_r2eff, select_spin_index):
607 """Setup of data SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
608
609 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
610 'SOD1-WT' CPMG data to the CR72 dispersion model.
611
612 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
613 Data is for experiment at 25 degree Celcius.
614 """
615
616
617 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'sod1wt_t25'
618
619
620 Exps = [
621 ["600MHz", "Z_A", 599.8908617*1E6, 0.06, [28, 0, 4, 32, 60, 2, 10, 16, 8, 20, 50, 18, 40, 6, 12, 0, 24], ["Z_A1", "Z_A15"] ],
622 ["500MHz", "Z_B", 499.862139*1E6, 0.04, [20, 0, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28, 0], ["Z_B1", "Z_B18"] ] ]
623
624
625 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
626
627
628 id_lists = []
629 for folder, key, sfrq, time_T2, ncycs, rep_ncyss in Exps:
630
631 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
632 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
633
634
635 id_list = list(key+str(i) for i in range(len(ncycs)))
636 id_lists.append(id_list)
637
638
639 self.interpreter.spectrum.read_intensities(file="128_FT.ser", dir=data_path+sep+folder, int_method='height', spectrum_id=id_list, int_col=list(range(len(id_list))) )
640
641
642 for i in range(len(ncycs)):
643 ncyc = ncycs[i]
644 vcpmg = ncyc/time_T2
645
646
647 if float(vcpmg) == 0.0:
648 vcpmg = None
649 else:
650 vcpmg = round(float(vcpmg), 3)
651
652
653 current_id = id_list[i]
654
655
656 self.interpreter.relax_disp.exp_type(spectrum_id=current_id, exp_type='SQ CPMG')
657
658
659 self.interpreter.spectrometer.frequency(id=current_id, frq=sfrq, units='Hz')
660
661
662 self.interpreter.relax_disp.relax_time(spectrum_id=current_id, time=time_T2)
663
664
665 self.interpreter.relax_disp.cpmg_setup(spectrum_id=current_id, cpmg_frq=vcpmg)
666
667
668 self.interpreter.spectrum.replicated(spectrum_ids=Exps[0][5])
669 self.interpreter.spectrum.replicated(spectrum_ids=Exps[1][5])
670
671
672 self.interpreter.spectrum.error_analysis(subset=id_lists[0])
673 self.interpreter.spectrum.error_analysis(subset=id_lists[1])
674
675
676 self.interpreter.spin.isotope(isotope='15N')
677
678
679
680
681 glob_assn = ["G10N-H", "D11N-H", "Q15N-H", "G16N-H", "G37N-H", "G41N-H", "L42N-H", "H43N-H", "H46N-H", "V47N-H", "E49N-H",
682 "E50N-H", "E51N-H", "N53N-H", "T54N-H", "G56N-H", "C57N-H", "T58N-H", "G61N-H", "H63aN-H", "F64aN-H", "N65aN-H",
683 "L67N-H", "S68N-H", "K70N-H", "G72N-H", "G73N-H", "K75N-H", "E78N-H", "R79N-H", "H80N-H", "V81N-H", "G82N-H",
684 "G85N-H", "N86N-H", "V87N-H", "S102N-H", "V103N-H", "I104N-H", "S105N-H", "A111N-H", "I112N-H", "R115N-H",
685 "V118N-H", "E121N-H", "A123N-H", "L126N-H", "G127N-H", "K128N-H", "G129N-H", "G130N-H", "N131N-H", "E133N-H",
686 "S134N-H", "T135N-H", "T137N-H", "G138N-H", "N139N-H", "A140N-H", "G141N-H", "S142N-H", "R143N-H", "C146N-H", "G147N-H"]
687
688
689 self.assertEqual(64, len(glob_assn ))
690
691
692
693 r = re.compile("([a-zA-Z]+)([0-9]+)([a-zA-Z]+)")
694
695
696 relax_glob_ids = []
697
698
699 for assn in glob_assn:
700
701 m = r.match(assn)
702
703 relax_string = ":%s@%s"%(m.group(2), m.group(3))
704
705
706 relax_glob_ids.append([m.group(0), m.group(1), m.group(2), m.group(3), relax_string])
707
708
709
710
711 self.interpreter.deselect.all()
712
713
714 for i in select_spin_index:
715 self.interpreter.select.spin(spin_id=relax_glob_ids[i][4], change_all=False)
716
717
718
719
720 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
721 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
722
723
724 MODEL = "R2eff"
725 self.interpreter.relax_disp.select_model(model=MODEL)
726
727 self.interpreter.minimise.calculate(verbosity=1)
728
729
731 """Function for setting up a few spins for the given pipe."""
732
733
734 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
735
736
737 file = open(data_path+sep+'R1_fitted_values.txt')
738 lines = file.readlines()
739 file.close()
740
741 for i, line in enumerate(lines):
742
743 line_split = line.split()
744
745 if line_split[0] == "#":
746 continue
747
748 mol_name = line_split[0]
749 mol_name = None
750 res_num = int(line_split[1])
751 res_name = line_split[2]
752 spin_num = line_split[3]
753 spin_num = None
754 spin_name = line_split[4]
755
756
757 self.interpreter.spin.create(spin_name=spin_name, spin_num=spin_num, res_name=res_name, res_num=res_num, mol_name=mol_name)
758
759
761 """Setup data for the test of relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data."""
762
763
764 self.interpreter.reset()
765
766
767 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
768 self.interpreter.state.load(data_path+sep+'r2eff_values')
769
770
771 model = 'NS R1rho 2-site'
772 pipe_name = "%s - relax_disp" % model
773 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
774 self.interpreter.pipe.switch(pipe_name=pipe_name)
775
776
777 self.interpreter.relax_disp.select_model(model=model)
778
779
780 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
781
782
783 spin1 = cdp.mol[0].res[0].spin[0]
784 spin2 = cdp.mol[0].res[1].spin[0]
785
786
787 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
788 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
789
790
791 spin1.r2 = {r20_key1: 9.9963793866185, r20_key2: 15.0056724422684}
792 spin1.pA = 0.779782428085762
793 spin1.dw = 7.57855284496424
794 spin1.kex = 1116.7911285203
795 spin2.r2 = {r20_key1: 11.9983346935434, r20_key2: 18.0076097513337}
796 spin2.pA = 0.826666229688602
797 spin2.dw = 9.5732624231366
798 spin2.kex = 1380.46162655657
799
800
801 if clustering:
802 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":1-100")
803
804
805 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
806
807
808 print("\n\nOptimised parameters:\n")
809 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
810 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
811 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
812 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
813 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
814 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
815 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
816
817
819 """Test synthetic data of Andrew J. Baldwin B14 model whereby the simplification R20A = R20B is assumed.
820
821 Support requst sr #3154 U{https://gna.org/support/index.php?3154}.
822
823 This uses the synthetic data from paper U{DOI: 10.1016/j.jmr.2014.02.023 <http://dx.doi.org/10.1016/j.jmr.2014.02.023>} with R20A, R20B = 2. rad/s.
824 """
825
826
827 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
828
829
830 pipe_name = 'base pipe'
831 pipe_type = 'relax_disp'
832 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
833
834
835 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
836
837
838 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
839
840
841 self.interpreter.spin.isotope('1H', spin_id='@H')
842
843
844
845 ncycs = [2, 4, 8, 10, 20, 40, 500]
846 ids = []
847 for ncyc in ncycs:
848 ids.append('CPMG_%s' % ncyc)
849
850 print("\n\nThe experiment IDs are %s." % ids)
851
852
853
854 sfrq = 200. * 1E6
855
856
857 Trelax = 0.04
858
859
860 for i in range(len(ids)):
861 id = ids[i]
862
863 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
864
865
866 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
867
868
869 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
870
871
872 ncyc = ncycs[i]
873 nu_cpmg = ncyc / Trelax
874 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
875
876
877 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
878 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
879
880
881 self.interpreter.relax_disp.r2eff_read_spin(id="CPMG", file="test_r2a_eq_r2b_w_error.out", dir=data_path, spin_id=':1@H', disp_point_col=1, data_col=2, error_col=3)
882
883
884 data = [
885 ['cpmg_frqs', {'CPMG_20': 500.0, 'CPMG_10': 250.0, 'CPMG_40': 1000.0, 'CPMG_4': 100.0, 'CPMG_2': 50.0, 'CPMG_500': 12500.0, 'CPMG_8': 200.0}],
886 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
887 ['dispersion_points', len(ncycs)],
888 ['exp_type', {'CPMG_20': 'SQ CPMG', 'CPMG_10': 'SQ CPMG', 'CPMG_40': 'SQ CPMG', 'CPMG_4': 'SQ CPMG', 'CPMG_2': 'SQ CPMG', 'CPMG_500': 'SQ CPMG', 'CPMG_8': 'SQ CPMG'}],
889 ['exp_type_list', ['SQ CPMG']],
890 ['spectrometer_frq', {'CPMG_20': 200000000.0, 'CPMG_10': 200000000.0, 'CPMG_40': 200000000.0, 'CPMG_4': 200000000.0, 'CPMG_2': 200000000.0, 'CPMG_500': 200000000.0, 'CPMG_8': 200000000.0}],
891 ['spectrometer_frq_count', 1],
892 ['spectrometer_frq_list', [sfrq]],
893 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
894 ]
895 for name, value in data:
896
897 self.assert_(hasattr(cdp, name))
898
899
900 obj = getattr(cdp, name)
901 if not isinstance(data, dict):
902 self.assertEqual(obj, value)
903
904
905 else:
906 for id in ids:
907 self.assertEqual(obj[id], value[id])
908
909
910 n_data = [
911 [ 50.000000, 10.367900, 0.1],
912 [ 100.000000, 10.146849, 0.1],
913 [ 200.000000, 9.765987, 0.1],
914 [ 250.000000, 9.409789, 0.1],
915 [ 500.000000, 5.829819, 0.1],
916 [ 1000.000000, 3.191928, 0.1],
917 [ 12500.000000, 2.008231, 0.1]
918 ]
919 for disp_point, value, error in n_data:
920 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
921 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
922 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
923
924
925 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
926
927
928 MODEL = "B14"
929
930
931 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
932 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
933 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
934
935
936 self.interpreter.relax_disp.select_model(model=MODEL)
937
938
939 grid_results = []
940 mini_results = []
941
942
943
944
945 GRID = 13
946
947 if GRID:
948
949
950 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
951
952
953 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
954
955
956 else:
957 for param in MODEL_PARAMS[MODEL]:
958 self.interpreter.value.set(param=param, index=None)
959
960 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
961
962
963 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
964 grid_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
965
966
967
968 set_func_tol = 1e-10
969 set_max_iter = 1000
970 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
971
972
973 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
974 mini_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
975
976
977 for i in range(len(grid_results)):
978 g_r2, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
979 m_r2, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
980 print("GRID %s r2=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
981 print("MIN %s r2=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
982
983
984
985 kex = 1000.
986
987 pb = 0.01
988
989 dw_ppm = 2.
990
991 R2g = 2.
992
993 R2e = 2.
994
995
996
997 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2[r20_key], R2g, 6)
998
999 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
1000 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 8)
1001 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex, kex, 3)
1002
1003
1005 """Test synthetic data of Andrew J. Baldwin B14 model. Support requst sr #3154 U{https://gna.org/support/index.php?3154}.
1006
1007 This uses the synthetic data from paper U{DOI: 10.1016/j.jmr.2014.02.023 <http://dx.doi.org/10.1016/j.jmr.2014.02.023>}.
1008 """
1009
1010
1011 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
1012
1013
1014 pipe_name = 'base pipe'
1015 pipe_type = 'relax_disp'
1016 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
1017
1018
1019 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
1020
1021
1022
1023 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
1024
1025
1026 self.interpreter.spin.isotope('1H', spin_id='@H')
1027
1028
1029
1030 ncycs = [2, 4, 8, 10, 20, 40, 500]
1031 ids = []
1032 for ncyc in ncycs:
1033 ids.append('CPMG_%s' % ncyc)
1034
1035 print("\n\nThe experiment IDs are %s." % ids)
1036
1037
1038
1039 sfrq = 200. * 1E6
1040
1041
1042 Trelax = 0.04
1043
1044
1045 for i in range(len(ids)):
1046 id = ids[i]
1047
1048 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
1049
1050
1051 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
1052
1053
1054 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
1055
1056
1057 ncyc = ncycs[i]
1058 nu_cpmg = ncyc / Trelax
1059 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
1060
1061
1062 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
1063 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
1064
1065
1066 self.interpreter.relax_disp.r2eff_read_spin(id="CPMG", file="test_w_error.out", dir=data_path, spin_id=':1@H', disp_point_col=1, data_col=2, error_col=3)
1067
1068
1069 data = [
1070 ['cpmg_frqs', {'CPMG_20': 500.0, 'CPMG_10': 250.0, 'CPMG_40': 1000.0, 'CPMG_4': 100.0, 'CPMG_2': 50.0, 'CPMG_500': 12500.0, 'CPMG_8': 200.0}],
1071 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
1072 ['dispersion_points', len(ncycs)],
1073 ['exp_type', {'CPMG_20': 'SQ CPMG', 'CPMG_10': 'SQ CPMG', 'CPMG_40': 'SQ CPMG', 'CPMG_4': 'SQ CPMG', 'CPMG_2': 'SQ CPMG', 'CPMG_500': 'SQ CPMG', 'CPMG_8': 'SQ CPMG'}],
1074 ['exp_type_list', ['SQ CPMG']],
1075 ['spectrometer_frq', {'CPMG_20': 200000000.0, 'CPMG_10': 200000000.0, 'CPMG_40': 200000000.0, 'CPMG_4': 200000000.0, 'CPMG_2': 200000000.0, 'CPMG_500': 200000000.0, 'CPMG_8': 200000000.0}],
1076 ['spectrometer_frq_count', 1],
1077 ['spectrometer_frq_list', [sfrq]],
1078 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
1079 ]
1080 for name, value in data:
1081
1082 self.assert_(hasattr(cdp, name))
1083
1084
1085 obj = getattr(cdp, name)
1086 if not isinstance(data, dict):
1087 self.assertEqual(obj, value)
1088
1089
1090 else:
1091 for id in ids:
1092 self.assertEqual(obj[id], value[id])
1093
1094
1095 n_data = [
1096 [ 50.000000, 10.286255, 0.1],
1097 [ 100.000000, 10.073083, 0.1],
1098 [ 200.000000, 9.692746, 0.1],
1099 [ 250.000000, 9.382441, 0.1],
1100 [ 500.000000, 6.312396, 0.1],
1101 [ 1000.000000, 3.957029, 0.1],
1102 [ 12500.000000, 2.880420, 0.1]
1103 ]
1104 for disp_point, value, error in n_data:
1105 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
1106 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
1107 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
1108
1109
1110 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
1111
1112
1113 MODEL = "B14 full"
1114
1115
1116 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
1117 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
1118 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
1119
1120
1121 self.interpreter.relax_disp.select_model(model=MODEL)
1122
1123
1124 grid_results = []
1125 mini_results = []
1126 clust_results = []
1127
1128
1129
1130
1131 GRID = 13
1132
1133 if GRID:
1134
1135
1136 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
1137
1138
1139 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
1140
1141
1142 else:
1143 for param in MODEL_PARAMS[MODEL]:
1144 self.interpreter.value.set(param=param, index=None)
1145
1146 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
1147
1148
1149 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1150 grid_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1151
1152
1153
1154 set_func_tol = 1e-11
1155 set_max_iter = 10000
1156 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
1157
1158
1159 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1160 mini_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1161
1162 print("\n# Now print before and after minimisation-\n")
1163
1164
1165 for i in range(len(grid_results)):
1166 g_r2a, g_r2b, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
1167 m_r2a, m_r2b, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
1168 print("GRID %s r2a=%2.4f r2b=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2a, g_r2b, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
1169 print("MIN %s r2b=%2.4f r2b=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2a, m_r2b, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
1170
1171
1172
1173 kex = 1000.
1174
1175 pb = 0.01
1176
1177 dw_ppm = 2.
1178
1179 R2g = 2.
1180
1181 R2e = 100.
1182
1183
1184
1185 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2a[r20_key], R2g, 4)
1186 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2b[r20_key], R2e, 2)
1187
1188 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
1189 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 6)
1190 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex, kex, 2)
1191
1192
1194 """U{Bug #21081<https://gna.org/bugs/?21081>} catch, the failure of a cluster analysis when spins are deselected."""
1195
1196
1197 self.interpreter.reset()
1198
1199
1200 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21081_disp_cluster_fail.bz2'
1201 self.interpreter.state.load(state, force=True)
1202
1203
1204 self.interpreter.model_selection(method='AIC', modsel_pipe='final', bundle='relax_disp', pipes=['No Rex', 'CR72'])
1205
1206
1208 """U{Bug #21460<https://gna.org/bugs/?21460>} catch, the failure due to a spectrometer frequency having no relaxation data."""
1209
1210
1211 self.interpreter.reset()
1212
1213
1214 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21460_bad_fields.bz2'
1215 self.interpreter.state.load(state, force=True)
1216
1217
1218 relax_disp.Relax_disp.opt_func_tol = 1e-5
1219 relax_disp.Relax_disp.opt_max_iterations = 1000
1220 relax_disp.Relax_disp(pipe_name="origin - relax_disp (Thu Jan 2 13:46:44 2014)", pipe_bundle="relax_disp (Thu Jan 2 13:46:44 2014)", results_dir=self.tmpdir, models=['R2eff', 'No Rex', 'CR72', 'NS CPMG 2-site expanded'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1221
1222
1224 """U{Bug #21665<https://gna.org/bugs/?21344>} catch, the failure of an analysis of a sparse acquired R1rho dataset with missing combinations of time and spin-lock field strengths using auto_analysis."""
1225
1226
1227 self.interpreter.reset()
1228
1229
1230 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
1231 self.interpreter.state.load(state, force=True)
1232
1233
1234 relax_disp.Relax_disp.opt_func_tol = 1e-5
1235 relax_disp.Relax_disp.opt_max_iterations = 1000
1236 relax_disp.Relax_disp(pipe_name='base pipe', pipe_bundle='relax_disp', results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1237
1238
1240 """U{Bug #21665<https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times, using minimise.calculate()."""
1241
1242
1243 self.interpreter.reset()
1244
1245
1246 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
1247 self.interpreter.state.load(state, force=True)
1248
1249
1250 self.interpreter.minimise.calculate(verbosity=1)
1251
1252
1254 """U{Bug #21665<https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times using auto_analysis."""
1255
1256
1257 self.interpreter.reset()
1258
1259
1260 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
1261 self.interpreter.state.load(state, force=True)
1262
1263
1264 relax_disp.Relax_disp.opt_func_tol = 1e-5
1265 relax_disp.Relax_disp.opt_max_iterations = 1000
1266 relax_disp.Relax_disp(pipe_name="compare_128_FT_R2eff", pipe_bundle="cpmg_disp_sod1d90a", results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1267
1268
1270 """Catch U{bug #21715<https://gna.org/bugs/?21715>}, the failure of a clustered auto-analysis due to an IndexError."""
1271
1272
1273 self.interpreter.reset()
1274
1275
1276 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'state.bz2'
1277 self.interpreter.state.load(state, force=True)
1278
1279
1280 pre_run_dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'non_clustered'
1281 relax_disp.Relax_disp.opt_func_tol = 1e-5
1282 relax_disp.Relax_disp.opt_max_iterations = 1000
1283 relax_disp.Relax_disp(pipe_name='origin - relax_disp (Sun Feb 23 19:36:51 2014)', pipe_bundle='relax_disp (Sun Feb 23 19:36:51 2014)', results_dir=self.tmpdir, models=['R2eff', 'No Rex'], grid_inc=11, mc_sim_num=2, modsel='AIC', pre_run_dir=pre_run_dir, insignificance=1.0, numeric_only=True, mc_sim_all_models=False, eliminate=True)
1284
1285
1291
1292
1298
1299
1305
1306
1312
1313
1315 """Catch U{bug #22146<https://gna.org/bugs/?22477>}, the failure of issuing: grace.write(x_data_type='res_num', y_data_type=param) for a mixed CPMG analysis."""
1316
1317
1318 self.interpreter.reset()
1319
1320
1321 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_22477_grace_write_k_AB_mixed_analysis'+sep+'bug_22477_results.bz2'
1322 self.interpreter.state.load(state, force=True)
1323
1324 param = 'k_AB'
1325
1326 for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
1327 print(spin_id, spin.params)
1328 if param in spin.params:
1329 print(spin_id, spin.k_AB, spin.k_AB_err)
1330
1331
1332 self.interpreter.grace.write(x_data_type='res_num', y_data_type=param, file='%s.agr'%param, dir=self.tmpdir, force=True)
1333
1334
1335
1336 param = 'r2'
1337 self.interpreter.value.write(param=param, file='%s.out'%param, dir=self.tmpdir, force=True)
1338
1339 file = open(self.tmpdir+sep+'%s.out'%param)
1340 lines = file.readlines()
1341 file.close()
1342
1343 for i, line in enumerate(lines):
1344
1345 line_split = line.split()
1346 print(line_split)
1347
1348 if len(line_split) > 1:
1349
1350 if line_split[0] == "#" and line_split[1] == 'mol_name':
1351 nr_split_header = len(line_split)
1352 nr_split_header_i = i
1353 break
1354
1355
1356 line_split_val = lines[nr_split_header_i + 1].split()
1357 print(line_split_val)
1358
1359
1360 self.assertEqual(nr_split_header, len(line_split_val) + 1)
1361
1362
1363 param = 'r2eff'
1364 self.interpreter.value.write(param=param, file='%s.out'%param, dir=self.tmpdir, force=True)
1365
1366 file = open(self.tmpdir+sep+'%s.out'%param)
1367 lines = file.readlines()
1368 file.close()
1369
1370 for i, line in enumerate(lines):
1371
1372 line_split = line.split()
1373 print(line_split)
1374
1375 if len(line_split) > 1:
1376
1377 if line_split[0] == "#" and line_split[1] == 'mol_name':
1378 nr_split_header = len(line_split)
1379 nr_split_header_i = i
1380 break
1381
1382
1383 line_split_val = lines[nr_split_header_i + 1].split()
1384 print(line_split_val)
1385
1386
1387 self.assertEqual(nr_split_header, len(line_split_val) + 1)
1388
1389
1391 """Catch U{bug #9999<https://gna.org/bugs/?9999>}, The slow optimisation of R1rho R2eff error estimation with Monte Carlo simulations."""
1392
1393
1394 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000" +sep+ "R2eff"
1395
1396
1397 self.interpreter.results.read(prev_data_path + sep + 'results')
1398
1399
1400 graph_nr = 1
1401 for exp_type, frq, offset, point in loop_exp_frq_offset_point(return_indices=False):
1402 print("\nGraph nr %i" % graph_nr)
1403 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
1404 print(exp_type, frq, offset, point, time)
1405 graph_nr += 1
1406
1407
1408
1409
1410 precalc = True
1411 for spin in spin_loop(skip_desel=True):
1412
1413 if not hasattr(spin, 'peak_intensity_err'):
1414 precalc = False
1415 break
1416
1417
1418 for id in cdp.spectrum_ids:
1419 if id not in spin.peak_intensity_err:
1420 precalc = False
1421 break
1422
1423
1424 if precalc:
1425 print("Skipping the error analysis as it has already been performed.")
1426
1427 else:
1428
1429 for frq in loop_frq():
1430
1431 ids = []
1432 for id in cdp.spectrum_ids:
1433
1434 match_frq = True
1435 if frq != None and cdp.spectrometer_frq[id] != frq:
1436 match_frq = False
1437
1438
1439 if match_frq:
1440 ids.append(id)
1441
1442
1443 self.interpreter.spectrum.error_analysis(subset=ids)
1444
1445 print("has_exponential_exp_type:", has_exponential_exp_type())
1446
1447 model = 'R2eff'
1448 self.interpreter.relax_disp.select_model(model)
1449
1450 for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
1451
1452
1453
1454
1455 setattr(spin, 'r2eff', {})
1456 setattr(spin, 'r2eff_err', {})
1457 setattr(spin, 'i0', {})
1458 setattr(spin, 'i0_err', {})
1459
1460
1461 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=21, constraints=True, verbosity=1)
1462
1463
1464 my_dic = {}
1465
1466
1467 NE = 0
1468 NS = 1
1469 NM = 0
1470 NO = 0
1471 ND = 0
1472 NT = 0
1473
1474 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1475
1476 if ei > NE:
1477 NE = ei
1478 if mi > NM:
1479 NM = mi
1480 if oi > NO:
1481 NO = oi
1482 if di > ND:
1483 ND = di
1484
1485 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1486
1487 if ti > NT:
1488 NT = ti
1489
1490
1491 NE = NE + 1
1492 NM = NM + 1
1493 NO = NO + 1
1494 ND = ND + 1
1495 NT = NT + 1
1496
1497
1498 values_arr = zeros([NE, NS, NM, NO, ND, NT])
1499 errors_arr = zeros([NE, NS, NM, NO, ND, NT])
1500 times_arr = zeros([NE, NS, NM, NO, ND, NT])
1501 struct_arr = zeros([NE, NS, NM, NO, ND, NT])
1502 param_key_list = []
1503
1504
1505
1506 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1507
1508 my_dic[spin_id] = {}
1509
1510
1511 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1512
1513
1514
1515
1516 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1517
1518 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1519
1520
1521 param_key_list.append(param_key)
1522
1523
1524 my_dic[spin_id][param_key] = {}
1525
1526
1527 R2eff_value = getattr(cur_spin, 'r2eff')[param_key]
1528 i0_value = getattr(cur_spin, 'i0')[param_key]
1529
1530
1531 my_dic[spin_id][param_key]['R2eff_value_grid'] = R2eff_value
1532 my_dic[spin_id][param_key]['i0_value_grid'] = i0_value
1533
1534
1535
1536 values = []
1537 errors = []
1538 times = []
1539 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1540 value = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, sim_index=None)
1541 values.append(value)
1542
1543 error = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True)
1544 errors.append(error)
1545 times.append(time)
1546
1547
1548 values_arr[ei, 0, mi, oi, di, ti] = value
1549 errors_arr[ei, 0, mi, oi, di, ti] = error
1550 times_arr[ei, 0, mi, oi, di, ti] = time
1551 struct_arr[ei, 0, mi, oi, di, ti] = 1.0
1552
1553
1554
1555
1556 w = log(array(values))
1557 x = - array(times)
1558 n = len(times)
1559
1560 b = (sum(x*w) - 1./n * sum(x) * sum(w) ) / ( sum(x**2) - 1./n * (sum(x))**2 )
1561 a = 1./n * sum(w) - b * 1./n * sum(x)
1562 R2eff_est = b
1563 i0_est = exp(a)
1564
1565 my_dic[spin_id][param_key]['R2eff_est'] = R2eff_est
1566 my_dic[spin_id][param_key]['i0_est'] = i0_est
1567
1568
1569
1570
1571
1572
1573
1574 set_func_tol = 1e-25
1575 set_max_iter = int(1e7)
1576 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
1577
1578
1579 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1580
1581 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1582
1583
1584 print("Optimised parameters for spin: %s" % (spin_string))
1585
1586 for exp_type, frq, offset, point in loop_exp_frq_offset_point():
1587
1588 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1589
1590
1591 R2eff_value = getattr(cur_spin, 'r2eff')[param_key]
1592 i0_value = getattr(cur_spin, 'i0')[param_key]
1593
1594
1595 R2eff_value_grid = my_dic[spin_id][param_key]['R2eff_value_grid']
1596 i0_value_grid = my_dic[spin_id][param_key]['i0_value_grid']
1597 R2eff_est = my_dic[spin_id][param_key]['R2eff_est']
1598 i0_est = my_dic[spin_id][param_key]['i0_est']
1599
1600
1601
1602
1603
1604 print("%-10s %-6s %-6s %3.1f : %3.1f: %3.1f" % ("Parameter:", 'R2eff', "Grid : Min : Estimated:", R2eff_value_grid, R2eff_value, R2eff_est))
1605 print("%-10s %-6s %-6s %3.1f : %3.1f: %3.1f" % ("Parameter:", 'i0', "Grid : Min : Estimated:", i0_value_grid, i0_value, i0_est))
1606
1607 print(NE, NS, NM, NO, ND, NT)
1608 for param_key in param_key_list:
1609 print(" '%s'," % param_key)
1610 print(values_arr.shape)
1611
1612
1613 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'curve_fitting'+sep+'profiling'+sep
1614
1615
1616
1617
1618
1619
1621 """Test data from Atul Srivastava. This is a bug missing raising a Relax Error, since the setup points to a situation where the data
1622 shows it is exponential fitting, but only one time point is added per file.
1623
1624 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1718>}:
1625 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1735>}:
1626 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1735/focus=1736>}:
1627
1628 """
1629
1630
1631 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_Atul_Srivastava'
1632 file = data_path + sep + 'bug_script.py'
1633
1634
1635 self.interpreter.script(file=file, dir=None)
1636
1637
1638 GRID_INC = 11
1639
1640
1641
1642
1643
1644 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1645 print(mol_name, resi, resn, spin_id)
1646
1647
1648 for id in cdp.exp_type.keys():
1649 print(id, cdp.exp_type[id], cdp.spectrometer_frq[id], cdp.spin_lock_offset[id], cdp.spin_lock_nu1[id])
1650
1651
1652
1653
1654 if True:
1655
1656 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
1657
1658
1659 check_intensity_errors()
1660
1661
1662 if cdp.model_type == MODEL_R2EFF and not has_exponential_exp_type():
1663 self.interpreter.minimise.calculate()
1664
1665
1666 else:
1667 constraints = False
1668 min_algor = 'Newton'
1669 with self.assertRaises(RelaxError):
1670 self.interpreter.minimise.grid_search(inc=GRID_INC)
1671
1672 with self.assertRaises(RelaxError):
1673 self.interpreter.minimise.execute(min_algor=min_algor, constraints=constraints)
1674
1675 if False:
1676
1677 par_attr_list = ['r2eff', 'i0']
1678
1679
1680 my_dic = {}
1681 param_key_list = []
1682 est_keys = []
1683 est_key = 'grid'
1684 est_keys.append(est_key)
1685 spin_id_list = []
1686
1687 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1688
1689 my_dic[spin_id] = {}
1690
1691
1692 my_dic[spin_id][est_key] = {}
1693
1694
1695 spin_id_list.append(spin_id)
1696
1697
1698 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1699
1700 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1701
1702 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1703
1704
1705
1706 param_key_list.append(param_key)
1707
1708
1709 my_dic[spin_id][est_key][param_key] = {}
1710
1711
1712
1713 for par_attr in par_attr_list:
1714 if hasattr(cur_spin, par_attr):
1715 get_par_attr = getattr(cur_spin, par_attr)[param_key]
1716 else:
1717 get_par_attr = 0.0
1718
1719
1720 my_dic[spin_id][est_key][param_key][par_attr] = get_par_attr
1721
1722
1723 values = []
1724 errors = []
1725 times = []
1726 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1727 value = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, sim_index=None)
1728 values.append(value)
1729
1730 error = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True)
1731 errors.append(error)
1732 times.append(time)
1733
1734
1735 my_dic[spin_id][est_key][param_key]['values'] = values
1736 my_dic[spin_id][est_key][param_key]['errors'] = errors
1737 my_dic[spin_id][est_key][param_key]['times'] = times
1738
1739
1740
1741
1742
1743 MODELS = ['R2eff', 'No Rex']
1744
1745
1746 MC_NUM = 10
1747
1748
1749 MC_SIM_ALL_MODELS = False
1750
1751
1752 RESULTS_DIR = ds.tmpdir
1753
1754
1755 PRE_RUN_DIR = None
1756
1757
1758 MODSEL = 'AIC'
1759
1760
1761 NUMERIC_ONLY = False
1762
1763
1764 INSIGNIFICANCE = 1.0
1765
1766
1767 with self.assertRaises(RelaxError):
1768 relax_disp.Relax_disp(pipe_name='relax_disp', results_dir=RESULTS_DIR, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, insignificance=INSIGNIFICANCE, numeric_only=NUMERIC_ONLY)
1769
1770
1772 """Test data, where peak intensities are negative in CPMG
1773
1774 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
1775 """
1776
1777 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+'bug_neg_int_acbp_cpmg_disp_048MGuHCl_40C_041223'
1778
1779
1780 self.interpreter.spectrum.read_spins(file="peaks_list_max_standard.ser", dir=data_path)
1781
1782
1783 self.interpreter.spin.isotope(isotope='15N')
1784
1785
1786 self.interpreter.spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=data_path, spectrum_id='auto', int_method='height')
1787
1788
1789 ncycfile=open(data_path + sep + 'ncyc.txt', 'r')
1790
1791
1792 ncyclist = []
1793
1794 i = 0
1795 for line in ncycfile:
1796 ncyc = line.split()[0]
1797 time_T2 = float(line.split()[1])
1798 vcpmg = line.split()[2]
1799 set_sfrq = float(line.split()[3])
1800 rmsd_err = float(line.split()[4])
1801
1802
1803 if float(vcpmg) == 0.0:
1804 vcpmg = None
1805 else:
1806 vcpmg = round(float(vcpmg), 3)
1807
1808
1809 ncyclist.append(int(ncyc))
1810
1811
1812 current_id = "Z_A%s"%(i)
1813
1814
1815 self.interpreter.relax_disp.exp_type(spectrum_id=current_id, exp_type='SQ CPMG')
1816
1817
1818 self.interpreter.spectrum.baseplane_rmsd(error=rmsd_err, spectrum_id=current_id)
1819
1820
1821 self.interpreter.spectrometer.frequency(id=current_id, frq=set_sfrq, units='MHz')
1822
1823
1824 self.interpreter.relax_disp.relax_time(spectrum_id=current_id, time=time_T2)
1825
1826
1827 self.interpreter.relax_disp.cpmg_setup(spectrum_id=current_id, cpmg_frq=vcpmg)
1828
1829 i += 1
1830
1831
1832 self.interpreter.spectrum.replicated(spectrum_ids=['Z_A1', 'Z_A15'])
1833
1834
1835
1836
1837 MODELS = [MODEL_R2EFF, MODEL_NOREX]
1838 GRID_INC = 5; MC_NUM = 3; MODSEL = 'AIC'
1839
1840 results_dir = ds.tmpdir
1841
1842
1843 relax_disp.Relax_disp(pipe_name='relax_disp', results_dir=results_dir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
1844
1845
1846 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
1847
1848 if spin_id == ':4@N':
1849 self.assertEqual(len(cur_spin.r2eff), 14)
1850 else:
1851 self.assertEqual(len(cur_spin.r2eff), 15)
1852
1853
1855 """Test of the check_missing_r1() function."""
1856
1857
1858 self.setup_missing_r1_spins()
1859
1860
1861 exp_type = 'R1rho'
1862 frq = 800.1 * 1E6
1863
1864 spectrum_id='test'
1865
1866
1867 self.interpreter.relax_disp.exp_type(spectrum_id=spectrum_id, exp_type=exp_type)
1868
1869
1870 self.interpreter.spectrometer.frequency(id=spectrum_id, frq=frq, units='Hz')
1871
1872
1873 check_missing_r1_return = check_missing_r1(model=MODEL_DPL94)
1874 self.assertEqual(check_missing_r1_return, True)
1875
1876
1877 check_missing_r1_return = check_missing_r1(model=MODEL_R2EFF)
1878 self.assertEqual(check_missing_r1_return, False)
1879
1880
1881 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
1882
1883
1884 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
1885
1886
1887 check_missing_r1_return = check_missing_r1(model=MODEL_DPL94)
1888 self.assertEqual(check_missing_r1_return, False)
1889
1890
1892 """Test synthetic cpmg data. Created with B14, analysed with NS CPMG 2site 3D, for clustered analysis.
1893
1894 This is part of: U{Task #7807 <https://gna.org/task/index.php?7807>}: Speed-up of dispersion models for Clustered analysis.
1895
1896 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
1897 """
1898
1899
1900
1901
1902
1903 model_create = 'B14'
1904
1905 model_analyse = 'NS CPMG 2-site 3D'
1906
1907
1908 sfrq_1 = 599.8908617*1E6
1909 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
1910 time_T2_1 = 0.06
1911 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
1912
1913 r2eff_errs_1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
1914 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
1915
1916 sfrq_2 = 499.8908617*1E6
1917 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
1918 time_T2_2 = 0.05
1919 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
1920
1921 r2eff_errs_2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
1922 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
1923
1924
1925 exps = [exp_1, exp_2]
1926
1927 spins = [
1928 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.95, 'dw': 2.} ],
1929 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.95, 'dw': 1.} ]
1930 ]
1931
1932
1933 ds.data = [model_create, model_analyse, spins, exps]
1934
1935
1936 ds.tmpdir = ds.tmpdir
1937
1938
1939
1940 ds.resdir = ds.tmpdir
1941
1942
1943 ds.r20_from_min_r2eff = True
1944
1945
1946 ds.insignificance = 0.0
1947
1948
1949 ds.GRID_INC = None
1950
1951
1952 ds.do_cluster = True
1953
1954
1955
1956 ds.set_func_tol = 1e-1
1957
1958
1959
1960 ds.set_max_iter = 1000
1961
1962
1963 ds.verbosity = 1
1964
1965
1966 ds.rel_change = 0.05
1967
1968
1969 ds.plot_curves = False
1970
1971
1972 ds.sherekhan_input = False
1973
1974
1975 ds.opendx = False
1976
1977
1978 ds.r2eff_err = 0.1
1979
1980
1981 ds.print_res = True
1982
1983
1984 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
1985
1986 cur_spins = ds.data[2]
1987
1988 for i in range(len(cur_spins)):
1989 res_name, res_num, spin_name, params = cur_spins[i]
1990 cur_spin_id = ":%i@%s"%(res_num, spin_name)
1991 cur_spin = return_spin(cur_spin_id)
1992
1993 grid_params = ds.grid_results[i][3]
1994
1995
1996 min_params = ds.clust_results[i][3]
1997
1998 print("For spin: '%s'"%cur_spin_id)
1999 for mo_param in cur_spin.params:
2000
2001 if isinstance(getattr(cur_spin, mo_param), dict):
2002 grid_r2 = grid_params[mo_param]
2003 min_r2 = min_params[mo_param]
2004 set_r2 = params[mo_param]
2005 for key, val in set_r2.items():
2006 grid_r2_frq = grid_r2[key]
2007 min_r2_frq = min_r2[key]
2008 set_r2_frq = set_r2[key]
2009 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2010 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2011 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2012 if rel_change > ds.rel_change:
2013 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2014 print("###################################")
2015
2016
2017 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2018 else:
2019 grid_val = grid_params[mo_param]
2020 min_val = min_params[mo_param]
2021 set_val = params[mo_param]
2022 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2023 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2024 if rel_change > ds.rel_change:
2025 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2026 print("###################################")
2027
2028
2029 if mo_param == 'dw':
2030 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2031 elif mo_param == 'kex':
2032 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2033 elif mo_param == 'pA':
2034 self.assertAlmostEqual(set_val, min_val, 2)
2035
2036
2038 """Test synthetic cpmg data. Created with B14, analysed with NS CPMG 2site STAR, for clustered analysis.
2039
2040 This is part of: U{Task #7807 <https://gna.org/task/index.php?7807>}: Speed-up of dispersion models for Clustered analysis.
2041
2042 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2043 """
2044
2045
2046
2047
2048
2049 model_create = 'B14'
2050
2051 model_analyse = 'NS CPMG 2-site star'
2052
2053
2054 sfrq_1 = 599.8908617*1E6
2055 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2056 time_T2_1 = 0.06
2057 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2058
2059 r2eff_errs_1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2060 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
2061
2062 sfrq_2 = 499.8908617*1E6
2063 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2064 time_T2_2 = 0.05
2065 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2066
2067 r2eff_errs_2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2068 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
2069
2070
2071 exps = [exp_1, exp_2]
2072
2073 spins = [
2074 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.95, 'dw': 2.} ],
2075 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.95, 'dw': 1.} ]
2076 ]
2077
2078
2079 ds.data = [model_create, model_analyse, spins, exps]
2080
2081
2082 ds.tmpdir = ds.tmpdir
2083
2084
2085
2086 ds.resdir = ds.tmpdir
2087
2088
2089 ds.r20_from_min_r2eff = True
2090
2091
2092 ds.insignificance = 0.0
2093
2094
2095 ds.GRID_INC = None
2096
2097
2098 ds.do_cluster = True
2099
2100
2101
2102 ds.set_func_tol = 1e-1
2103
2104
2105
2106 ds.set_max_iter = 1000
2107
2108
2109 ds.verbosity = 1
2110
2111
2112 ds.rel_change = 0.05
2113
2114
2115 ds.plot_curves = False
2116
2117
2118 ds.sherekhan_input = False
2119
2120
2121 ds.opendx = False
2122
2123
2124 ds.r2eff_err = 0.1
2125
2126
2127 ds.print_res = True
2128
2129
2130 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2131
2132 cur_spins = ds.data[2]
2133
2134 for i in range(len(cur_spins)):
2135 res_name, res_num, spin_name, params = cur_spins[i]
2136 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2137 cur_spin = return_spin(cur_spin_id)
2138
2139 grid_params = ds.grid_results[i][3]
2140
2141
2142 min_params = ds.clust_results[i][3]
2143
2144 print("For spin: '%s'"%cur_spin_id)
2145 for mo_param in cur_spin.params:
2146
2147 if isinstance(getattr(cur_spin, mo_param), dict):
2148 grid_r2 = grid_params[mo_param]
2149 min_r2 = min_params[mo_param]
2150 set_r2 = params[mo_param]
2151 for key, val in set_r2.items():
2152 grid_r2_frq = grid_r2[key]
2153 min_r2_frq = min_r2[key]
2154 set_r2_frq = set_r2[key]
2155 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2156 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2157 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2158 if rel_change > ds.rel_change:
2159 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2160 print("###################################")
2161
2162
2163 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2164 else:
2165 grid_val = grid_params[mo_param]
2166 min_val = min_params[mo_param]
2167 set_val = params[mo_param]
2168 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2169 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2170 if rel_change > ds.rel_change:
2171 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2172 print("###################################")
2173
2174
2175 if mo_param == 'dw':
2176 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2177 elif mo_param == 'kex':
2178 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2179 elif mo_param == 'pA':
2180 self.assertAlmostEqual(set_val, min_val, 2)
2181
2182
2184 """Test synthetic cpmg data.
2185
2186 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with CR72.
2187 """
2188
2189
2190
2191
2192
2193 model_create = 'NS CPMG 2-site 3D'
2194
2195 model_analyse = 'CR72'
2196
2197 sfrq_1 = 599.8908617*1E6
2198 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2199 time_T2_1 = 0.06
2200 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2201 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2202 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2203
2204 sfrq_2 = 499.8908617*1E6
2205 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2206 time_T2_2 = 0.05
2207 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2208 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2209 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2210
2211
2212 exps = [exp_1, exp_2]
2213
2214 spins = [
2215 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:10.}, 'r2a': {r20_key_1:10., r20_key_2:10.}, 'r2b': {r20_key_1:10., r20_key_2:10.}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ]
2216 ]
2217
2218
2219 ds.data = [model_create, model_analyse, spins, exps]
2220
2221
2222 ds.tmpdir = ds.tmpdir
2223
2224
2225
2226 ds.resdir = ds.tmpdir
2227
2228
2229 ds.r20_from_min_r2eff = True
2230
2231
2232 ds.insignificance = 0.0
2233
2234
2235 ds.GRID_INC = 8
2236
2237
2238 ds.do_cluster = False
2239
2240
2241
2242 ds.set_func_tol = 1e-9
2243
2244
2245
2246 ds.set_max_iter = 1000
2247
2248
2249 ds.verbosity = 1
2250
2251
2252 ds.rel_change = 0.05
2253
2254
2255 ds.plot_curves = False
2256
2257
2258 ds.sherekhan_input = False
2259
2260
2261 ds.opendx = False
2262
2263
2264 ds.r2eff_err = 0.1
2265
2266
2267 ds.print_res = False
2268
2269
2270 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2271
2272 cur_spins = ds.data[2]
2273
2274 for i in range(len(cur_spins)):
2275 res_name, res_num, spin_name, params = cur_spins[i]
2276 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2277 cur_spin = return_spin(cur_spin_id)
2278
2279 grid_params = ds.grid_results[i][3]
2280 min_params = ds.min_results[i][3]
2281
2282 print("For spin: '%s'"%cur_spin_id)
2283 for mo_param in cur_spin.params:
2284
2285 if isinstance(getattr(cur_spin, mo_param), dict):
2286 grid_r2 = grid_params[mo_param]
2287 min_r2 = min_params[mo_param]
2288 set_r2 = params[mo_param]
2289 for key, val in set_r2.items():
2290 grid_r2_frq = grid_r2[key]
2291 min_r2_frq = min_r2[key]
2292 set_r2_frq = set_r2[key]
2293 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2294 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2295 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2296 if rel_change > ds.rel_change:
2297 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2298 print("###################################")
2299
2300
2301 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
2302 else:
2303 grid_val = grid_params[mo_param]
2304 min_val = min_params[mo_param]
2305 set_val = params[mo_param]
2306 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2307 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2308 if rel_change > ds.rel_change:
2309 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2310 print("###################################")
2311
2312
2313 if mo_param == 'dw':
2314 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2315 elif mo_param == 'kex':
2316 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2317 elif mo_param == 'pA':
2318 self.assertAlmostEqual(set_val, min_val, 3)
2319
2320
2322 """Test synthetic cpmg data.
2323
2324 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with B14.
2325 Try to catch bug #22021 U{https://gna.org/bugs/index.php?22021}: Model B14 shows bad fitting to data.
2326 """
2327
2328
2329
2330
2331
2332 model_create = 'NS CPMG 2-site 3D'
2333
2334 model_analyse = 'B14'
2335
2336 sfrq_1 = 599.8908617*1E6
2337 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2338 time_T2_1 = 0.06
2339 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2340 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2341 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2342
2343 sfrq_2 = 499.8908617*1E6
2344 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2345 time_T2_2 = 0.05
2346 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2347 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2348 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2349
2350
2351 exps = [exp_1, exp_2]
2352
2353 spins = [
2354 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:10.}, 'r2a': {r20_key_1:10., r20_key_2:10.}, 'r2b': {r20_key_1:10., r20_key_2:10.}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ]
2355 ]
2356
2357
2358 ds.data = [model_create, model_analyse, spins, exps]
2359
2360
2361 ds.tmpdir = ds.tmpdir
2362
2363
2364
2365 ds.resdir = ds.tmpdir
2366
2367
2368 ds.r20_from_min_r2eff = True
2369
2370
2371 ds.insignificance = 0.0
2372
2373
2374 ds.GRID_INC = 8
2375
2376
2377 ds.do_cluster = False
2378
2379
2380
2381 ds.set_func_tol = 1e-9
2382
2383
2384
2385 ds.set_max_iter = 1000
2386
2387
2388 ds.verbosity = 1
2389
2390
2391 ds.rel_change = 0.05
2392
2393
2394 ds.plot_curves = False
2395
2396
2397 ds.sherekhan_input = False
2398
2399
2400 ds.opendx = False
2401
2402
2403 ds.r2eff_err = 0.1
2404
2405
2406 ds.print_res = False
2407
2408
2409 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2410
2411 cur_spins = ds.data[2]
2412
2413 for i in range(len(cur_spins)):
2414 res_name, res_num, spin_name, params = cur_spins[i]
2415 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2416 cur_spin = return_spin(cur_spin_id)
2417
2418 grid_params = ds.grid_results[i][3]
2419 min_params = ds.min_results[i][3]
2420
2421 print("For spin: '%s'"%cur_spin_id)
2422 for mo_param in cur_spin.params:
2423
2424 if isinstance(getattr(cur_spin, mo_param), dict):
2425 grid_r2 = grid_params[mo_param]
2426 min_r2 = min_params[mo_param]
2427 set_r2 = params[mo_param]
2428 for key, val in set_r2.items():
2429 grid_r2_frq = grid_r2[key]
2430 min_r2_frq = min_r2[key]
2431 set_r2_frq = set_r2[key]
2432 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2433 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2434 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2435 if rel_change > ds.rel_change:
2436 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2437 print("###################################")
2438
2439
2440 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
2441 else:
2442 grid_val = grid_params[mo_param]
2443 min_val = min_params[mo_param]
2444 set_val = params[mo_param]
2445 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2446 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2447 if rel_change > ds.rel_change:
2448 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2449 print("###################################")
2450
2451
2452 if mo_param == 'dw':
2453 self.assertAlmostEqual(set_val/10, min_val/10, 5)
2454 elif mo_param == 'kex':
2455 self.assertAlmostEqual(set_val/1000, min_val/1000, 5)
2456 elif mo_param == 'pA':
2457 self.assertAlmostEqual(set_val, min_val, 6)
2458
2459
2461 """Test synthetic cpmg data. For CR72 with small noise and cluster.
2462
2463 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2464 """
2465
2466
2467
2468
2469
2470 model_create = 'NS CPMG 2-site 3D'
2471
2472 model_analyse = 'CR72'
2473
2474
2475 sfrq_1 = 599.8908617*1E6
2476 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2477 time_T2_1 = 0.06
2478 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2479 r2eff_errs_1 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
2480
2481 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
2482
2483 sfrq_2 = 499.8908617*1E6
2484 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2485 time_T2_2 = 0.05
2486 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2487 r2eff_errs_2 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
2488
2489 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
2490
2491
2492 exps = [exp_1, exp_2]
2493
2494 spins = [
2495 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ],
2496 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.99, 'dw': 1.} ]
2497 ]
2498
2499
2500 ds.data = [model_create, model_analyse, spins, exps]
2501
2502
2503 ds.tmpdir = ds.tmpdir
2504
2505
2506
2507 ds.resdir = ds.tmpdir
2508
2509
2510 ds.r20_from_min_r2eff = True
2511
2512
2513 ds.insignificance = 0.0
2514
2515
2516 ds.GRID_INC = 13
2517
2518
2519 ds.do_cluster = True
2520
2521
2522
2523 ds.set_func_tol = 1e-8
2524
2525
2526
2527 ds.set_max_iter = 10000
2528
2529
2530 ds.verbosity = 1
2531
2532
2533 ds.rel_change = 0.05
2534
2535
2536 ds.plot_curves = False
2537
2538
2539 ds.sherekhan_input = False
2540
2541
2542 ds.opendx = False
2543
2544
2545 ds.r2eff_err = 0.1
2546
2547
2548 ds.print_res = False
2549
2550
2551 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2552
2553 cur_spins = ds.data[2]
2554
2555 for i in range(len(cur_spins)):
2556 res_name, res_num, spin_name, params = cur_spins[i]
2557 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2558 cur_spin = return_spin(cur_spin_id)
2559
2560 grid_params = ds.grid_results[i][3]
2561
2562
2563 min_params = ds.clust_results[i][3]
2564
2565 print("For spin: '%s'"%cur_spin_id)
2566 for mo_param in cur_spin.params:
2567
2568 if isinstance(getattr(cur_spin, mo_param), dict):
2569 grid_r2 = grid_params[mo_param]
2570 min_r2 = min_params[mo_param]
2571 set_r2 = params[mo_param]
2572 for key, val in set_r2.items():
2573 grid_r2_frq = grid_r2[key]
2574 min_r2_frq = min_r2[key]
2575 set_r2_frq = set_r2[key]
2576 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2577 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2578 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2579 if rel_change > ds.rel_change:
2580 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2581 print("###################################")
2582
2583
2584 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2585 else:
2586 grid_val = grid_params[mo_param]
2587 min_val = min_params[mo_param]
2588 set_val = params[mo_param]
2589 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2590 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2591 if rel_change > ds.rel_change:
2592 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2593 print("###################################")
2594
2595
2596 if mo_param == 'dw':
2597 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2598 elif mo_param == 'kex':
2599 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2600 elif mo_param == 'pA':
2601 self.assertAlmostEqual(set_val, min_val, 2)
2602
2603
2605 """Test synthetic cpmg data, calling the dx.map function with one or two points.
2606
2607 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2608 """
2609
2610
2611
2612
2613
2614 model_create = MODEL_NS_CPMG_2SITE_EXPANDED
2615 model_analyse = 'CR72'
2616
2617 sfrq_1 = 599.8908617*1E6
2618 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2619 time_T2_1 = 0.06
2620 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2621 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2622 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2623
2624 sfrq_2 = 499.8908617*1E6
2625 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2626 time_T2_2 = 0.05
2627 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2628 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2629 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2630
2631
2632 exps = [exp_1, exp_2]
2633
2634 spins = [
2635 ['Ala', 1, 'N', {'r2': {r20_key_1:2, r20_key_2:2}, 'r2a': {r20_key_1:2, r20_key_2:2}, 'r2b': {r20_key_1:2, r20_key_2:2}, 'kex': 1000, 'pA': 0.99, 'dw': 2} ]
2636 ]
2637
2638
2639 ds.data = [model_create, model_analyse, spins, exps]
2640
2641
2642 ds.tmpdir = ds.tmpdir
2643
2644
2645
2646 ds.resdir = ds.tmpdir
2647
2648
2649 ds.r20_from_min_r2eff = True
2650
2651
2652 ds.insignificance = 0.0
2653
2654
2655 ds.GRID_INC = None
2656
2657
2658 ds.do_cluster = False
2659
2660
2661
2662 ds.set_func_tol = 1e-9
2663
2664
2665
2666 ds.set_max_iter = 1000
2667
2668
2669 ds.verbosity = 1
2670
2671
2672 ds.rel_change = 0.05
2673
2674
2675 ds.plot_curves = False
2676
2677
2678 ds.sherekhan_input = False
2679
2680
2681 ds.opendx = False
2682
2683
2684 ds.r2eff_err = 0.1
2685
2686
2687 ds.print_res = False
2688
2689
2690 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2691
2692
2693 cur_spins = ds.data[2]
2694
2695
2696 ds.pipe_name_MODEL_MAP = "%s_%s_map"%(ds.pipe_name, model_analyse)
2697 self.interpreter.pipe.copy(pipe_from=ds.pipe_name, pipe_to=ds.pipe_name_MODEL_MAP, bundle_to = ds.pipe_bundle)
2698 self.interpreter.pipe.switch(pipe_name=ds.pipe_name_MODEL_MAP)
2699
2700
2701 self.interpreter.value.copy(pipe_from=ds.pipe_name_r2eff, pipe_to=ds.pipe_name_MODEL_MAP, param='r2eff')
2702
2703
2704 self.interpreter.relax_disp.select_model(model=model_analyse)
2705
2706
2707 ds.dx_inc = 4
2708 ds.dx_params = ['dw', 'pA', 'kex']
2709
2710 res_name, res_num, spin_name, params = cur_spins[0]
2711 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2712 cur_spin = return_spin(cur_spin_id)
2713
2714 print("Params for dx map is")
2715 print(ds.dx_params)
2716 print("Point param for dx map is")
2717 print(ds.dx_set_val)
2718 cur_model = model_analyse.replace(' ', '_')
2719 file_name_map = "%s_map%s" % (cur_model, cur_spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
2720 file_name_point = "%s_point%s" % (cur_model, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
2721 self.interpreter.dx.map(params=ds.dx_params, map_type='Iso3D', spin_id=cur_spin_id, inc=ds.dx_inc, lower=None, upper=None, axis_incs=10, file_prefix=file_name_map, dir=ds.resdir, point=[ds.dx_set_val, ds.dx_clust_val], point_file=file_name_point)
2722
2723
2724
2725 map_cfg = ds.tmpdir+sep+file_name_map+".cfg"
2726 map_net = ds.tmpdir+sep+file_name_map+".net"
2727 map_general = ds.tmpdir+sep+file_name_map+".general"
2728
2729 point_general = ds.tmpdir+sep+file_name_point+".general"
2730 point_point = ds.tmpdir+sep+file_name_point
2731
2732
2733 self.assert_(access(map_cfg, F_OK))
2734 self.assert_(access(map_net, F_OK))
2735 self.assert_(access(map_general, F_OK))
2736 self.assert_(access(point_general, F_OK))
2737 self.assert_(access(point_point, F_OK))
2738
2739
2740
2741 print("\nChecking the dx map .cfg file.")
2742 res_file = [
2743 '//'+"\n",
2744 '//'+"\n",
2745 '// time: Thu May 8 18:55:31 2014'+"\n",
2746 '//'+"\n",
2747 '// version: 3.2.0 (format), 4.3.2 (DX)'+"\n",
2748 '//'+"\n",
2749 '//'+"\n",
2750 '// panel[0]: position = (0.0164,0.0000), size = 0.2521x0.1933, startup = 1, devstyle = 1'+"\n",
2751 '// title: value = Control Panel'+"\n",
2752 '//'+"\n",
2753 '// workspace: width = 251, height = 142'+"\n",
2754 '// layout: snap = 0, width = 50, height = 50, align = NN'+"\n",
2755 '//'+"\n",
2756 '// interactor Selector[1]: num_components = 1, value = 1 '+"\n",
2757 '// selections: maximum = 2, current = 0 '+"\n",
2758 '// option[0]: name = "Colour", value = 1'+"\n",
2759 '// option[1]: name = "Grey", value = 2'+"\n",
2760 '// instance: panel = 0, x = 81, y = 6, style = Scrolled List, vertical = 1, size = 170x136'+"\n",
2761 '// label: value = Colour Selector'+"\n",
2762 '//'+"\n",
2763 '// node Image[3]:'+"\n",
2764 '// title: value = Surface'+"\n",
2765 '// depth: value = 24'+"\n",
2766 '// window: position = (0.0000,0.0400), size = 0.9929x0.9276'+"\n",
2767 ]
2768 file = open(map_cfg, 'r')
2769 lines = file.readlines()
2770 file.close()
2771 for i in range(len(res_file)):
2772
2773 if i == 2:
2774 continue
2775 self.assertEqual(res_file[i], lines[i])
2776
2777 print("\nChecking the dx map .general file.")
2778 res_file = [
2779 'file = CR72_map_1_N'+"\n",
2780 'grid = 5 x 5 x 5'+"\n",
2781 'format = ascii'+"\n",
2782 'interleaving = field'+"\n",
2783 'majority = row'+"\n",
2784 'field = data'+"\n",
2785 'structure = scalar'+"\n",
2786 'type = float'+"\n",
2787 'dependency = positions'+"\n",
2788 'positions = regular, regular, regular, 0, 1, 0, 1, 0, 1'+"\n",
2789 ''+"\n",
2790 'end'+"\n",
2791 ]
2792 file = open(map_general, 'r')
2793 lines = file.readlines()
2794 file.close()
2795 for i in range(len(res_file)):
2796
2797
2798
2799 self.assertEqual(res_file[i], lines[i])
2800
2801 print("\nChecking the dx point .general file.")
2802 res_file = [
2803 'file = CR72_point_1_N'+"\n",
2804 'points = 2'+"\n",
2805 'format = ascii'+"\n",
2806 'interleaving = field'+"\n",
2807 'field = locations, field0'+"\n",
2808 'structure = 3-vector, scalar'+"\n",
2809 'type = float, float'+"\n",
2810 ''+"\n",
2811 'end'+"\n",
2812 ]
2813 file = open(point_general, 'r')
2814 lines = file.readlines()
2815 file.close()
2816 for i in range(len(res_file)):
2817
2818
2819
2820 self.assertEqual(res_file[i], lines[i])
2821
2822 print("\nChecking the dx point point file.")
2823 res_file = [
2824 '0.8 3.92 0.39964 1'+"\n",
2825 '0.76981 3.9169 0.41353 1'+"\n",
2826 ]
2827 file = open(point_point, 'r')
2828 lines = file.readlines()
2829 file.close()
2830 for i in range(len(res_file)):
2831
2832
2833
2834 self.assertEqual(res_file[i], lines[i])
2835
2836
2838 """Test the curve type detection using the Dr. Flemming Hansen's CPMG fixed time test data."""
2839
2840
2841 self.interpreter.reset()
2842
2843
2844 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
2845 self.interpreter.state.load(data_path+sep+'r2eff_values')
2846
2847
2848 curve_type = get_curve_type(id='500_133.33.in')
2849 self.assertEqual(curve_type, 'fixed time')
2850
2851
2853 """Test the curve type detection using the 'M61' exponential test data."""
2854
2855
2856 self.interpreter.reset()
2857
2858
2859 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_on_res_m61'
2860 self.interpreter.state.load(data_path+sep+'r2eff_values')
2861
2862
2863 curve_type = get_curve_type(id='nu_2000_ncyc9')
2864 self.assertEqual(curve_type, 'exponential')
2865
2866
2868 """Test the curve type detection using the 'TP02' fixed time test data."""
2869
2870
2871 self.interpreter.reset()
2872
2873
2874 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
2875 self.interpreter.state.load(data_path+sep+'r2eff_values')
2876
2877
2878 curve_type = get_curve_type(id='nu_1000.0_500MHz')
2879 self.assertEqual(curve_type, 'fixed time')
2880
2881
2883 """Test the relaxation dispersion 'DPL94' model curve fitting to fixed time synthetic data."""
2884
2885
2886 ds.fixed = True
2887
2888
2889 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_dpl94.py')
2890
2891
2892 i0 = [100000.0, 20000.0]
2893 r1rho_prime = [2.25, 24.0]
2894 pA = 0.7
2895 kex = 1000.0
2896 delta_omega = [1.0, 2.0]
2897 phi_ex = []
2898 for i in range(2):
2899 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
2900
2901
2902 self.interpreter.pipe.switch('DPL94 - relax_disp')
2903 spin_index = 0
2904 for spin, spin_id in spin_loop(return_id=True):
2905
2906 print("\nSpin %s." % spin_id)
2907
2908
2909 self.assertAlmostEqual(spin.r2['R1rho - 800.00000000 MHz']/10, r1rho_prime[spin_index]/10, 2)
2910 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
2911 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
2912
2913
2914 spin_index += 1
2915
2916
2918 """Test the user function for estimating R2eff errors from exponential curve fitting.
2919
2920 This follows Task 7822.
2921 U{task #7822<https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
2922
2923 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
2924 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
2925 """
2926
2927
2928 cluster_ids = [
2929 ":13@N",
2930 ":15@N",
2931 ":16@N",
2932 ":25@N",
2933 ":26@N",
2934 ":28@N",
2935 ":39@N",
2936 ":40@N",
2937 ":41@N",
2938 ":43@N",
2939 ":44@N",
2940 ":45@N",
2941 ":49@N",
2942 ":52@N",
2943 ":53@N"]
2944
2945
2946 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids, read_R1=False)
2947
2948
2949 MODELS = [MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
2950
2951
2952 GRID_INC = None
2953
2954
2955 MC_NUM = 3
2956
2957
2958 MODSEL = 'AIC'
2959
2960
2961
2962 OPT_FUNC_TOL = 1e-25
2963 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
2964 OPT_MAX_ITERATIONS = 10000000
2965 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
2966
2967 result_dir_name = ds.tmpdir
2968
2969
2970 for curspin in cluster_ids:
2971 self.interpreter.relax_disp.cluster('free spins', curspin)
2972
2973 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
2974
2975
2976
2977
2978
2979
2980
2981
2982 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
2983
2984
2985
2986 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
2987
2988
2989 check_intensity_errors()
2990
2991
2992 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=11, constraints=True, verbosity=1)
2993
2994
2995 self.interpreter.minimise.execute(min_algor='Newton', constraints=False, verbosity=1)
2996
2997
2998 self.interpreter.relax_disp.r2eff_err_estimate()
2999
3000 r1_fit = True
3001
3002
3003 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, r1_fit=r1_fit)
3004
3005
3006 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='direct')
3007
3008
3010 """Test the user function for estimating R2eff errors from exponential curve fitting, via the auto_analyses menu.
3011
3012 This follows Task 7822.
3013 U{task #7822<https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
3014
3015 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3016 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3017 """
3018
3019
3020 cluster_ids = [
3021 ":13@N",
3022 ":15@N",
3023 ":16@N",
3024 ":25@N",
3025 ":26@N",
3026 ":28@N",
3027 ":39@N",
3028 ":40@N",
3029 ":41@N",
3030 ":43@N",
3031 ":44@N",
3032 ":45@N",
3033 ":49@N",
3034 ":52@N",
3035 ":53@N"]
3036
3037
3038
3039 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep
3040
3041
3042 pipe_name = 'base pipe'
3043 pipe_bundle = 'relax_disp'
3044 pipe_type = 'relax_disp'
3045
3046
3047 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type)
3048
3049 file = data_path + '1_setup_r1rho_GUI.py'
3050 self.interpreter.script(file=file, dir=None)
3051
3052
3053 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
3054
3055
3056 GRID_INC = None
3057
3058
3059
3060
3061 EXP_MC_NUM = -1
3062
3063
3064 MC_NUM = 3
3065
3066
3067 MODSEL = 'AIC'
3068
3069
3070
3071 OPT_FUNC_TOL = 1e-25
3072 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
3073 OPT_MAX_ITERATIONS = 10000000
3074 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
3075
3076
3077
3078
3079
3080
3081
3082
3083 self.interpreter.deselect.spin(spin_id=':1-100', change_all=False)
3084
3085
3086
3087
3088
3089
3090
3091
3092 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
3093
3094
3095 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3096 print(spin_id)
3097
3098 result_dir_name = self.tmpdir
3099 r1_fit = True
3100
3101
3102 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, exp_mc_sim_num=EXP_MC_NUM, modsel=MODSEL, r1_fit=r1_fit)
3103
3104
3105 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='direct')
3106
3107
3109 """Test the user function for estimating R2eff and associated errors for exponential curve fitting with different methods.
3110 This is compared with a run where erros are estimated by 2000 Monte Carlo simulations.
3111
3112 This follows Task 7822.
3113 U{task #7822<https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
3114
3115 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3116 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3117
3118 NOTE: The difference in the methods was due to a bug in relax!
3119 U{bug #22554<https://gna.org/bugs/index.php?22554>}. The distribution of intensity with errors in Monte-Carlo simulations are markedly more narrow than expected.
3120
3121 This dataset is old, and includes 2000 Monte-Carlo simulations, which is performed wrong.
3122 """
3123
3124
3125 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000" +sep+ "R2eff"
3126
3127
3128 self.interpreter.pipe.create('MC_2000', 'relax_disp')
3129
3130
3131 self.interpreter.results.read(prev_data_path + sep + 'results')
3132
3133
3134 my_dic = {}
3135 param_key_list = []
3136
3137
3138 do_boot = True
3139 if do_boot:
3140 min_algor = 'Newton'
3141 min_options = ()
3142 sim_boot = 200
3143 scaling_list = [1.0, 1.0]
3144
3145
3146 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3147
3148 my_dic[spin_id] = {}
3149
3150
3151 for i, r2eff_sim in enumerate(cur_spin.r2eff_sim):
3152
3153 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3154
3155 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3156 r2eff_sim_point = r2eff_sim[param_key]
3157 i0_sim_point = cur_spin.r2eff_sim[i][param_key]
3158
3159
3160
3161
3162 self.assert_(r2eff_sim_point > 0.0)
3163 self.assert_(i0_sim_point > 0.0)
3164
3165
3166 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3167
3168 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
3169
3170 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3171
3172 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3173
3174
3175 r2eff_sim_l = []
3176 i0_sim_l = []
3177 for i, r2eff_sim in enumerate(cur_spin.r2eff_sim):
3178 i0_sim = cur_spin.i0_sim[i]
3179
3180 r2eff_sim_i = r2eff_sim[param_key]
3181 r2eff_sim_l.append(r2eff_sim_i)
3182 i0_sim_i = i0_sim[param_key]
3183 i0_sim_l.append(i0_sim_i)
3184
3185
3186 r2eff_sim_err = std(asarray(r2eff_sim_l), ddof=1)
3187 i0_sim_err = std(asarray(i0_sim_l), ddof=1)
3188
3189
3190 param_key_list.append(param_key)
3191
3192
3193 my_dic[spin_id][param_key] = {}
3194
3195
3196 r2eff = getattr(cur_spin, 'r2eff')[param_key]
3197 r2eff_err = getattr(cur_spin, 'r2eff_err')[param_key]
3198 i0 = getattr(cur_spin, 'i0')[param_key]
3199 i0_err = getattr(cur_spin, 'i0_err')[param_key]
3200
3201
3202 my_dic[spin_id][param_key]['r2eff'] = r2eff
3203 my_dic[spin_id][param_key]['r2eff_err'] = r2eff_err
3204 my_dic[spin_id][param_key]['i0'] = i0
3205 my_dic[spin_id][param_key]['i0_err'] = i0_err
3206 my_dic[spin_id][param_key]['r2eff_err_sim'] = r2eff_sim_err
3207 my_dic[spin_id][param_key]['i0_err_sim'] = i0_sim_err
3208
3209
3210 self.assertAlmostEqual(r2eff_sim_err, r2eff_err)
3211 self.assertAlmostEqual(i0_sim_err, i0_err)
3212
3213 if do_boot:
3214 values = []
3215 errors = []
3216 times = []
3217 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
3218 values.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time))
3219 errors.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True))
3220 times.append(time)
3221
3222
3223 values = asarray(values)
3224 errors = asarray(errors)
3225 times = asarray(times)
3226
3227 R_m_sim_l = []
3228 I0_m_sim_l = []
3229 for j in range(sim_boot):
3230 if j in range(0, 100000, 100):
3231 print("Simulation %i"%j)
3232
3233
3234
3235 I_err = []
3236 for j, error in enumerate(errors):
3237 I_error = gauss(values[j], error)
3238 I_err.append(I_error)
3239
3240 I_err = asarray(I_err)
3241
3242 x0 = [r2eff, i0]
3243 setup(num_params=len(x0), num_times=len(times), values=I_err, sd=errors, relax_times=times, scaling_matrix=scaling_list)
3244
3245 params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=func, dfunc=dfunc, d2func=d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, full_output=True, print_flag=0)
3246 R_m_sim_j, I0_m_sim_j = params_minfx_sim_j
3247 R_m_sim_l.append(R_m_sim_j)
3248 I0_m_sim_l.append(I0_m_sim_j)
3249
3250
3251 sigma_R_sim = std(asarray(R_m_sim_l), ddof=1)
3252 sigma_I0_sim = std(asarray(I0_m_sim_l), ddof=1)
3253 my_dic[spin_id][param_key]['r2eff_err_boot'] = sigma_R_sim
3254 my_dic[spin_id][param_key]['i0_err_boot'] = sigma_I0_sim
3255
3256
3257
3258 self.interpreter.pipe.copy(pipe_from='MC_2000', pipe_to='r2eff_est')
3259 self.interpreter.pipe.switch(pipe_name='r2eff_est')
3260
3261
3262 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3263 delattr(cur_spin, 'r2eff_err')
3264 delattr(cur_spin, 'i0_err')
3265
3266
3267 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
3268
3269
3270 self.interpreter.relax_disp.r2eff_err_estimate(verbosity=0)
3271
3272 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3273
3274 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
3275
3276 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3277
3278 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3279
3280
3281 r2eff_est = getattr(cur_spin, 'r2eff')[param_key]
3282 r2eff_err_est = getattr(cur_spin, 'r2eff_err')[param_key]
3283 i0_est = getattr(cur_spin, 'i0')[param_key]
3284 i0_err_est = getattr(cur_spin, 'i0_err')[param_key]
3285
3286
3287 r2eff = my_dic[spin_id][param_key]['r2eff']
3288 r2eff_err = my_dic[spin_id][param_key]['r2eff_err']
3289 i0 = my_dic[spin_id][param_key]['i0']
3290 i0_err = my_dic[spin_id][param_key]['i0_err']
3291 r2eff_sim_err = my_dic[spin_id][param_key]['r2eff_err_sim']
3292 i0_sim_err = my_dic[spin_id][param_key]['i0_err_sim']
3293
3294 if do_boot:
3295 r2eff_boot_err = my_dic[spin_id][param_key]['r2eff_err_boot']
3296 i0_boot_err = my_dic[spin_id][param_key]['i0_err_boot']
3297 else:
3298 r2eff_boot_err = 0.0
3299 i0_boot_err = 0.0
3300
3301 print("%s at %3.1f MHz, for offset=%3.3f ppm and dispersion point %-5.1f." % (exp_type, frq/1E6, offset, point) )
3302 print("r2eff=%3.3f/%3.3f r2eff_err=%3.4f/%3.4f/%3.4f/%3.4f" % (r2eff, r2eff_est, r2eff_err, r2eff_err_est, r2eff_sim_err, r2eff_boot_err) ),
3303 print("i0=%3.3f/%3.3f i0_err=%3.4f/%3.4f/%3.4f/%3.4f\n" % (i0, i0_est, i0_err, i0_err_est, i0_sim_err, i0_boot_err) )
3304
3305
3306
3307 estimate_r2eff(method='scipy.optimize.leastsq')
3308
3309 estimate_r2eff(method='minfx', min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=False)
3310 estimate_r2eff(method='minfx', min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=True)
3311
3312 estimate_r2eff(method='minfx', min_algor='simplex', c_code=False, constraints=False, chi2_jacobian=False)
3313 estimate_r2eff(method='minfx', min_algor='simplex', c_code=False, constraints=False, chi2_jacobian=True)
3314
3315 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=True, constraints=False, chi2_jacobian=False)
3316 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=True, constraints=False, chi2_jacobian=True)
3317
3318 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=False, constraints=False, chi2_jacobian=False)
3319 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=False, constraints=False, chi2_jacobian=True)
3320
3321 estimate_r2eff(method='minfx', min_algor='Newton', c_code=True, constraints=False, chi2_jacobian=False)
3322 estimate_r2eff(method='minfx', min_algor='Newton', c_code=True, constraints=False, chi2_jacobian=True)
3323
3324
3325
3327 """Test the relaxation dispersion 'exp_fit' model curve fitting."""
3328
3329
3330 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'exp_fit.py')
3331
3332
3333 res_data = [
3334 [15., 10., 20000., 25000.],
3335 [12., 11., 50000., 51000.],
3336 [17., 9., 100000., 96000.]
3337 ]
3338
3339
3340 blacklist = ['cpmg_frqs', 'r2', 'rex', 'kex', 'r2a', 'k_AB', 'dw']
3341
3342
3343 for i in range(len(res_data)):
3344
3345 print("\nResidue number %s." % (i+1))
3346
3347
3348 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_1000.000'], res_data[i][0], places=2)
3349 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_2000.000'], res_data[i][1], places=2)
3350 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_1000.000']/10000, res_data[i][2]/10000, places=3)
3351 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_2000.000']/10000, res_data[i][3]/10000, places=3)
3352
3353
3354 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_1000.000'] < 5.0)
3355 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_2000.000'] < 5.0)
3356 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_1000.000']/10000 < 5.0)
3357 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_2000.000']/10000 < 5.0)
3358
3359
3360 for param in blacklist:
3361 print("\tChecking for the absence of the '%s' parameter." % param)
3362 self.assert_(not hasattr(cdp.mol[0].res[i].spin[0], param))
3363
3364
3365 self.assert_(hasattr(cdp, 'clustering'))
3366 keys = ['free spins', 'cluster']
3367 for key in keys:
3368 self.assert_(key in cdp.clustering)
3369 self.assert_('test' not in cdp.clustering)
3370 self.assertEqual(cdp.clustering['free spins'], [':2@N'])
3371 self.assertEqual(cdp.clustering['cluster'], [':1@N', ':3@N'])
3372
3373
3375 """Test return from C code, when parameters are wrong. This can happen, if minfx takes a wrong step."""
3376
3377 times = array([ 0.7, 1., 0.8, 0.4, 0.9])
3378 I = array([ 476.76174875, 372.43328777, 454.20339981, 656.87936253, 419.16726341])
3379 errors = array([ 9.48032653, 11.34093541, 9.35149017, 10.84867928, 12.17590736])
3380
3381 scaling_list = [1.0, 1.0]
3382 setup(num_params=2, num_times=len(times), values=I, sd=errors, relax_times=times, scaling_matrix=scaling_list)
3383
3384 R = - 500.
3385 I0 = 1000.
3386 params = [R, I0]
3387
3388 chi2 = func(params)
3389
3390 print("The chi2 value returned from C-code for R=%3.2f and I0=%3.2f, then chi2=%3.2f"%(R, I0, chi2))
3391 self.assertNotEqual(chi2, inf)
3392
3393
3504
3505
3507 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
3508
3509 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3510 """
3511
3512
3513 ds.models = [
3514 MODEL_NOREX,
3515 MODEL_LM63,
3516 MODEL_CR72,
3517 MODEL_IT99
3518 ]
3519
3520
3521 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
3522 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
3523
3524
3525 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3526 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3527
3528
3529 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
3530 spin70 = return_spin(":70")
3531 spin71 = return_spin(":71")
3532 print("\n\nOptimised parameters:\n")
3533 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3534 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3535 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3536 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3537 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
3538 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
3539 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
3540 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
3541 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
3542 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
3543
3544
3545 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
3546 spin70 = return_spin(":70")
3547 spin71 = return_spin(":71")
3548 print("\n\nOptimised parameters:\n")
3549 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3550 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3551 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3552 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
3553 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3554 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3555 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
3556 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
3557 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
3558 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
3559 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
3560 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
3561 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
3562 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
3563 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
3564 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
3565
3566
3567 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
3568 spin70 = return_spin(":70")
3569 spin71 = return_spin(":71")
3570 print("\n\nOptimised parameters:\n")
3571 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3572 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3573 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3574 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3575 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3576 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3577 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3578 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
3579 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
3580 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
3581 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
3582 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
3583 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
3584 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
3585 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
3586 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
3587 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
3588 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
3589 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
3590
3591
3593 """Test of the numeric model only dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
3594
3595 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3596 """
3597
3598
3599 ds.models = [
3600 MODEL_NOREX,
3601 MODEL_CR72,
3602 MODEL_NS_CPMG_2SITE_EXPANDED
3603 ]
3604 ds.numeric_only = True
3605
3606
3607 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
3608
3609
3610 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3611 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3612
3613
3614 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
3615 spin70 = return_spin(":70")
3616 spin71 = return_spin(":71")
3617 print("\n\nOptimised parameters:\n")
3618 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3619 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3620 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3621 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3622 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
3623 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
3624 self.assertAlmostEqual(spin70.chi2/10000, 8973.84810025761/10000, 3)
3625 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
3626 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
3627 self.assertAlmostEqual(spin71.chi2/10000, 3908.00127830003/10000, 3)
3628
3629
3630 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
3631 spin70 = return_spin(":70")
3632 spin71 = return_spin(":71")
3633 print("\n\nOptimised parameters:\n")
3634 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3635 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3636 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3637 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3638 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3639 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3640 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3641 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
3642 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
3643 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
3644 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
3645 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
3646 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
3647 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
3648 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
3649 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
3650 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
3651 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
3652 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
3653
3654
3655 self.interpreter.pipe.switch(pipe_name='NS CPMG 2-site expanded - relax_disp')
3656 spin70 = return_spin(":70")
3657 spin71 = return_spin(":71")
3658 print("\n\nOptimised parameters:\n")
3659 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3660 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3661 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3662 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3663 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3664 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3665 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3666 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95815351460902, 3)
3667 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39649535771294, 3)
3668 self.assertAlmostEqual(spin70.pA, 0.989701014493195, 3)
3669 self.assertAlmostEqual(spin70.dw, 5.67314464776128, 3)
3670 self.assertAlmostEqual(spin70.kex/10000, 1713.65380495429/10000, 3)
3671 self.assertAlmostEqual(spin70.chi2, 52.5106880917473, 3)
3672 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99889337382435, 3)
3673 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89822887466673, 3)
3674 self.assertAlmostEqual(spin71.pA, 0.986709050819695, 3)
3675 self.assertAlmostEqual(spin71.dw, 2.09238266766502, 2)
3676 self.assertAlmostEqual(spin71.kex/10000, 2438.27019901422/10000, 3)
3677 self.assertAlmostEqual(spin71.chi2, 15.1644906963987, 3)
3678
3679
3680 self.interpreter.pipe.switch(pipe_name='final - relax_disp')
3681 spin70 = return_spin(":70")
3682 spin71 = return_spin(":71")
3683 self.assertEqual(spin70.model, 'NS CPMG 2-site expanded')
3684 self.assertEqual(spin71.model, 'NS CPMG 2-site expanded')
3685
3686
3688 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data (using the R2eff data directly instead of peak intensities).
3689
3690 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3691 """
3692
3693
3694 ds.models = [
3695 MODEL_NOREX,
3696 MODEL_LM63,
3697 MODEL_CR72,
3698 MODEL_IT99
3699 ]
3700
3701
3702 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_r2eff_data.py')
3703 self.interpreter.state.save('analysis_r2eff', dir=ds.tmpdir, force=True)
3704
3705
3706 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3707 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3708
3709
3710 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
3711 spin70 = return_spin(":70")
3712 spin71 = return_spin(":71")
3713 print("\n\nOptimised parameters:\n")
3714 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3715 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3716 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3717 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3718 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
3719 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
3720 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
3721 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
3722 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
3723 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
3724
3725
3726 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
3727 spin70 = return_spin(":70")
3728 spin71 = return_spin(":71")
3729 print("\n\nOptimised parameters:\n")
3730 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3731 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3732 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3733 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
3734 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3735 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3736 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
3737 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
3738 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
3739 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
3740 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
3741 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
3742 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
3743 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
3744 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
3745 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
3746
3747
3748 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
3749 spin70 = return_spin(":70")
3750 spin71 = return_spin(":71")
3751 print("\n\nOptimised parameters:\n")
3752 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3753 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3754 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3755 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3756 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3757 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3758 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3759 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
3760 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
3761 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
3762 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
3763 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
3764 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
3765 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00317154730225, 3)
3766 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797713541, 3)
3767 self.assertAlmostEqual(spin71.pA, 0.985922406429147, 3)
3768 self.assertAlmostEqual(spin71.dw, 2.00500965887772, 2)
3769 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579804/10000, 3)
3770 self.assertAlmostEqual(spin71.chi2, 15.6595374288635, 3)
3771
3772
3774 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data with parts missing.
3775
3776 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3777 """
3778
3779
3780 ds.models = [
3781 MODEL_R2EFF,
3782 MODEL_NOREX,
3783 MODEL_CR72,
3784 MODEL_NS_CPMG_2SITE_EXPANDED
3785 ]
3786
3787
3788 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data_missing.py')
3789 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
3790
3791
3792 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3793 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3794
3795
3796 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
3797 spin4 = return_spin(":4")
3798 spin70 = return_spin(":70")
3799 spin71 = return_spin(":71")
3800 print("\n\nOptimised parameters:\n")
3801 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
3802 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
3803 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
3804 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
3805 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463084515171, 3)
3806 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63220784651911, 3)
3807 self.assertAlmostEqual(spin4.chi2, 26.7356700694891, 3)
3808 self.assertAlmostEqual(spin70.r2[r20_key1], 10.534285641325, 3)
3809 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112794857068, 3)
3810 self.assertAlmostEqual(spin70.chi2, 8973.84809774722, 3)
3811 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83136858890037, 3)
3812 self.assertAlmostEqual(spin71.chi2, 182.60081909193, 3)
3813
3814
3815 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
3816 spin4 = return_spin(":4")
3817 spin70 = return_spin(":70")
3818 spin71 = return_spin(":71")
3819 print("\n\nOptimised parameters:\n")
3820 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
3821 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
3822 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
3823 print("%-20s %20.15g %20.15g %20.15g" % ("pA", spin4.pA, spin70.pA, spin71.pA))
3824 print("%-20s %20.15g %20.15g %20.15g" % ("dw", spin4.dw, spin70.dw, spin71.dw))
3825 print("%-20s %20.15g %20.15g %20.15g" % ("kex", spin4.kex, spin70.kex, spin71.kex))
3826 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
3827 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463650370664, 2)
3828 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63221675941434, 3)
3829
3830 self.assertAlmostEqual(spin4.dw, 0.0, 5)
3831 self.assertAlmostEqual(spin4.kex/10000, 0.0, 3)
3832 self.assertAlmostEqual(spin4.chi2/100, 26.7356711142038/100, 3)
3833 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97268077496405, 3)
3834 self.assertAlmostEqual(spin70.r2[r20_key2], 9.41028133407727, 3)
3835 self.assertAlmostEqual(spin70.pA, 0.989856641885939, 3)
3836 self.assertAlmostEqual(spin70.dw, 5.60889911049405, 3)
3837 self.assertAlmostEqual(spin70.kex/10000, 1752.62025618632/10000, 3)
3838 self.assertAlmostEqual(spin70.chi2, 53.8382196964083, 3)
3839 self.assertAlmostEqual(spin71.r2[r20_key1], 4.98123328466942, 3)
3840 self.assertAlmostEqual(spin71.pA, 0.996607425484157, 3)
3841 self.assertAlmostEqual(spin71.dw, 4.34346257383825, 3)
3842 self.assertAlmostEqual(spin71.kex/10000, 1936.73197158804/10000, 3)
3843 self.assertAlmostEqual(spin71.chi2, 5.51703791653689, 3)
3844
3845
3847 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 dispersion model.
3848
3849 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3850 """
3851
3852
3853 self.setup_hansen_cpmg_data(model='CR72')
3854
3855
3856 spin70 = return_spin(":70")
3857 spin71 = return_spin(":71")
3858
3859
3860 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3861 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3862
3863
3864 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
3865 spin70.pA = 0.9
3866 spin70.dw = 6.0
3867 spin70.kex = 1500.0
3868 spin71.r2 = {r20_key1: 5, r20_key2: 9.0}
3869 spin71.pA = 0.9
3870 spin71.dw = 4.0
3871 spin71.kex = 1900.0
3872
3873
3874 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
3875
3876
3877 print("\n\nOptimised parameters:\n")
3878 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3879 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
3880 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
3881 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3882 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3883 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3884 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3885
3886
3887 self.assertAlmostEqual(spin70.r2[r20_key1], 6.9724581325007, 4)
3888 self.assertAlmostEqual(spin70.r2[r20_key2], 9.40968331038162, 2)
3889 self.assertAlmostEqual(spin70.pA, 0.989856656702431, 4)
3890 self.assertAlmostEqual(spin70.dw, 5.60885879594746, 3)
3891 self.assertAlmostEqual(spin70.kex/1000, 1752.91052702273/1000, 3)
3892 self.assertAlmostEqual(spin70.chi2, 53.8382133597495, 4)
3893
3894
3895 self.assertAlmostEqual(spin71.r2[r20_key1], 5.0030740940524, 4)
3896 self.assertAlmostEqual(spin71.pA, 0.985941082507823, 4)
3897 self.assertAlmostEqual(spin71.dw, 2.00640384113696, 4)
3898 self.assertAlmostEqual(spin71.kex/1000, 2480.79614442041/1000, 4)
3899 self.assertAlmostEqual(spin71.chi2, 15.6595388312451, 4)
3900
3901
3902 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
3903 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
3904
3905
3906 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
3907 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
3908
3909
3911 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 full dispersion model.
3912
3913 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3914 """
3915
3916
3917 self.setup_hansen_cpmg_data(model='CR72 full')
3918
3919
3920 spin70 = return_spin(":70")
3921 spin71 = return_spin(":71")
3922
3923
3924 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3925 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3926
3927
3928 spin70.r2a = {r20_key1: 7.0, r20_key2: 9.0}
3929 spin70.r2b = {r20_key1: 7.0, r20_key2: 9.0}
3930 spin70.pA = 0.9
3931 spin70.dw = 6.0
3932 spin70.kex = 1500.0
3933 spin71.r2a = {r20_key1: 5.0, r20_key2: 9.0}
3934 spin71.r2b = {r20_key1: 5.0, r20_key2: 9.0}
3935 spin71.pA = 0.9
3936 spin71.dw = 4.0
3937 spin71.kex = 1900.0
3938
3939
3940 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
3941
3942
3943 print("\n\nOptimised parameters:\n")
3944 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
3945 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
3946 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
3947 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
3948 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
3949 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
3950 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
3951 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
3952 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
3953
3954
3955 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.87485258365614, 4)
3956 self.assertAlmostEqual(spin70.r2b[r20_key1], 1.26075839074614, 4)
3957 self.assertAlmostEqual(spin70.r2a[r20_key2], 8.79580446260797, 4)
3958 self.assertAlmostEqual(spin70.r2b[r20_key2], 51.188411562843, 4)
3959 self.assertAlmostEqual(spin70.pA, 0.989384178573802, 4)
3960 self.assertAlmostEqual(spin70.dw, 5.54738203723682, 4)
3961 self.assertAlmostEqual(spin70.kex/1000, 1831.4566463179/1000, 4)
3962 self.assertAlmostEqual(spin70.chi2, 50.450410782403, 4)
3963
3964
3965 self.assertAlmostEqual(spin71.r2a[r20_key1], 5.04185695754972, 4)
3966 self.assertAlmostEqual(spin71.r2b[r20_key1], 1.62857899941921, 4)
3967 self.assertAlmostEqual(spin71.pA, 0.988832866751676, 4)
3968 self.assertAlmostEqual(spin71.dw, 2.24905251856265, 4)
3969 self.assertAlmostEqual(spin71.kex/1000, 2397.64122642946/1000, 4)
3970 self.assertAlmostEqual(spin71.chi2, 15.8586492923672, 4)
3971
3972
3973 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
3974 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
3975
3976
3977 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
3978 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
3979
3980
3982 """Optimisation of Dr. Flemming Hansen's CPMG data to the IT99 dispersion model.
3983
3984 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3985 """
3986
3987
3988 self.setup_hansen_cpmg_data(model='IT99')
3989
3990
3991 spin70 = return_spin(":70")
3992 spin71 = return_spin(":71")
3993
3994
3995 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3996 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3997
3998
3999 spin70.r2 = {r20_key1: 8.8, r20_key2: 16.6}
4000 spin70.dw = 10.0
4001 spin70.pA = 0.5
4002 spin70.tex = 1000.09
4003 spin71.r2 = {r20_key1: 1.0, r20_key2: 1.0}
4004 spin71.dw = 10.0
4005 spin71.pA = 0.95
4006 spin71.tex = 0.1
4007
4008
4009 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-10, grad_tol=None, max_iter=10000, constraints=True, scaling=True, verbosity=1)
4010
4011
4012 print("\n\nOptimised parameters:\n")
4013 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4014 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4015 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4016 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4017 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4018 print("%-20s %20.15g %20.15g" % ("tex", spin70.tex, spin71.tex))
4019 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4020
4021
4022 self.assertAlmostEqual(spin70.r2[r20_key1], 7.24471197811838, 4)
4023 self.assertAlmostEqual(spin70.r2[r20_key2], 10.0571040704729, 4)
4024 self.assertAlmostEqual(spin70.dw, 5.2116923222744, 4)
4025 self.assertAlmostEqual(spin70.pA, 0.990253627907212, 4)
4026 self.assertAlmostEqual(spin70.tex*1000, 0.000638394793480444*1000, 4)
4027 self.assertAlmostEqual(spin70.chi2, 93.5135798618747, 4)
4028
4029
4030 self.assertAlmostEqual(spin71.r2[r20_key1], 5.05971235970214, 4)
4031 self.assertAlmostEqual(spin71.r2[r20_key2], 6.96641194493447, 4)
4032 self.assertAlmostEqual(spin71.dw, 0.435389946897141, 4)
4033 self.assertAlmostEqual(spin71.pA, 0.500000000213519, 3)
4034 self.assertAlmostEqual(spin71.tex*1000, 0.000372436400585538*1000, 4)
4035 self.assertAlmostEqual(spin71.chi2, 23.7895798801404, 4)
4036
4037
4039 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model.
4040
4041 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4042 """
4043
4044
4045 self.setup_hansen_cpmg_data(model='LM63')
4046
4047
4048 spin70 = return_spin(":70")
4049 spin71 = return_spin(":71")
4050
4051
4052 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4053 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4054
4055
4056 spin70.r2 = {r20_key1: 7.0, r20_key2: 7.0}
4057 spin70.phi_ex = 0.3
4058 spin70.kex = 5000.0
4059 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
4060 spin71.phi_ex = 0.1
4061 spin71.kex = 2500.0
4062
4063
4064 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-25, grad_tol=None, max_iter=10000000, constraints=True, scaling=True, verbosity=1)
4065
4066
4067 print("\n\nOptimised parameters:\n")
4068 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4069 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4070 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4071 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
4072 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4073 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4074
4075
4076 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74362294539099)
4077 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406797067481, 6)
4078 self.assertAlmostEqual(spin70.phi_ex, 0.312733013751449)
4079 self.assertAlmostEqual(spin70.kex/1000, 4723.09897146338/1000, 6)
4080 self.assertAlmostEqual(spin70.chi2, 363.534044873483)
4081
4082
4083 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00776657729728, 5)
4084 self.assertAlmostEqual(spin71.phi_ex, 0.0553787825650613, 5)
4085 self.assertAlmostEqual(spin71.kex/1000, 2781.72292994154/1000, 5)
4086 self.assertAlmostEqual(spin71.chi2, 17.0776399916287, 5)
4087
4088
4090 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model.
4091
4092 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4093 """
4094
4095
4096 self.setup_hansen_cpmg_data(model='LM63 3-site')
4097
4098
4099 spin70 = return_spin(":70")
4100 spin71 = return_spin(":71")
4101
4102
4103 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4104 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4105
4106
4107 spin70.r2 = {r20_key1: 7.570370921220954, r20_key2: 8.694446951909107}
4108 spin70.phi_ex_B = 0.14872003058250227
4109 spin70.phi_ex_C = 0.1319419923472704
4110 spin70.kB = 4103.672910444741
4111 spin70.kC = 7029.001690726248
4112 spin71.r2 = {r20_key1: 5.1347793381636, r20_key2: 7.156573986051575}
4113 spin71.phi_ex_B = 0.04013553485505605
4114 spin71.phi_ex_C = 0.020050748406928887
4115 spin71.kB = 4045.3007136121364
4116 spin71.kC = 3586.38798270774
4117
4118
4119
4120
4121
4122 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-25, grad_tol=None, max_iter=10000000, constraints=True, scaling=True, verbosity=1)
4123
4124
4125 print("\n\nOptimised parameters:\n")
4126 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4127 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4128 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4129 print("%-20s %20.15g %20.15g" % ("phi_ex_B", spin70.phi_ex_B, spin71.phi_ex_B))
4130 print("%-20s %20.15g %20.15g" % ("phi_ex_C", spin70.phi_ex_C, spin71.phi_ex_C))
4131 print("%-20s %20.15g %20.15g" % ("kB", spin70.kB, spin71.kB))
4132 print("%-20s %20.15g %20.15g" % ("kC", spin70.kC, spin71.kC))
4133 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4134
4135
4136 self.assertAlmostEqual(spin70.r2[r20_key1], 6.7436230253685, 5)
4137 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406813008828, 6)
4138 self.assertAlmostEqual(spin70.phi_ex_B, 0.206304023079778, 5)
4139 self.assertAlmostEqual(spin70.phi_ex_C, 0.106428983339627, 5)
4140 self.assertAlmostEqual(spin70.kB/1000, 4723.09897652589/1000, 6)
4141 self.assertAlmostEqual(spin70.kC/1000, 4723.09876196409/1000, 6)
4142 self.assertAlmostEqual(spin70.chi2, 363.534044873483, 5)
4143
4144
4145 self.assertAlmostEqual(spin71.r2[r20_key1], 4.96612095596752, 5)
4146 self.assertAlmostEqual(spin71.phi_ex_B, 0.00398262266512895, 5)
4147 self.assertAlmostEqual(spin71.phi_ex_C, 0.0555791581291262, 5)
4148 self.assertAlmostEqual(spin71.kB/1000, 1323.33195689832/1000, 5)
4149 self.assertAlmostEqual(spin71.kC/1000, 3149.58971568059/1000, 5)
4150 self.assertAlmostEqual(spin71.chi2, 16.2620934464368)
4151
4152
4154 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D' dispersion model.
4155
4156 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4157 """
4158
4159
4160 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D')
4161
4162
4163 spin70 = return_spin(":70")
4164 spin71 = return_spin(":71")
4165
4166
4167 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4168 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4169
4170
4171 spin70.r2 = {r20_key1: 6.994165925, r20_key2: 9.428129427}
4172 spin70.pA = 0.9897754407
4173 spin70.dw = 5.642418428
4174 spin70.kex = 1743.666375
4175 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
4176 spin71.pA = 0.9968032899
4177 spin71.dw = 4.577891393
4178 spin71.kex = 1830.044597
4179
4180
4181 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4182
4183
4184 print("\n\nOptimised parameters:\n")
4185 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4186 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4187 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4188 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4189 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4190 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4191 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4192
4193
4194 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95797760459016, 4)
4195 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39628959312699, 4)
4196 self.assertAlmostEqual(spin70.pA, 0.989700985380975, 4)
4197 self.assertAlmostEqual(spin70.dw, 5.6733714171086, 4)
4198 self.assertAlmostEqual(spin70.kex/1000, 1713.63101361545/1000, 4)
4199 self.assertAlmostEqual(spin70.chi2, 52.5106928523775, 4)
4200
4201
4202 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99893565849977, 4)
4203 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89825625944034, 4)
4204 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 4)
4205 self.assertAlmostEqual(spin71.dw, 2.09292495350993, 4)
4206 self.assertAlmostEqual(spin71.kex/1000, 2438.04423541463/1000, 4)
4207 self.assertAlmostEqual(spin71.chi2, 15.164490242352, 4)
4208
4209
4210 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4211 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4212
4213
4214 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4215 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4216
4217
4219 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D full' dispersion model.
4220
4221 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4222 """
4223
4224
4225 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D full')
4226
4227
4228 spin70 = return_spin(":70")
4229 spin71 = return_spin(":71")
4230
4231
4232 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4233 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4234
4235
4236 spin70.r2a = {r20_key1: 6.644753428, r20_key2: 7.891776687}
4237 spin70.r2b = {r20_key1: 7.163478485, r20_key2: 138.5170395}
4238 spin70.pA = 0.9884781357
4239 spin70.dw = 5.456507396
4240 spin70.kex = 1906.521189
4241 spin71.r2a = {r20_key1: 4.99893524108981, r20_key2: 100.0}
4242 spin71.r2b = {r20_key1: 8.27456243639973, r20_key2: 100.0}
4243 spin71.pA = 0.986709616684097
4244 spin71.dw = 2.09245158280905
4245 spin71.kex = 2438.2766211401
4246
4247
4248 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4249
4250
4251 print("\n\nOptimised parameters:\n")
4252 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4253 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
4254 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
4255 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
4256 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
4257 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4258 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4259 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4260 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4261
4262
4263 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.61176004043484, 4)
4264 self.assertAlmostEqual(spin70.r2b[r20_key1], 7.4869316381241, 4)
4265 self.assertAlmostEqual(spin70.r2a[r20_key2], 7.78200386067591, 4)
4266 self.assertAlmostEqual(spin70.r2b[r20_key2], 141.703593742468, 4)
4267 self.assertAlmostEqual(spin70.pA, 0.988404987055969, 4)
4268 self.assertAlmostEqual(spin70.dw, 5.4497360203213, 4)
4269 self.assertAlmostEqual(spin70.kex/1000, 1934.09304607082/1000, 4)
4270 self.assertAlmostEqual(spin70.chi2, 44.6793752187925, 4)
4271
4272
4273 self.assertAlmostEqual(spin71.r2a[r20_key1], 4.6013095731966, 4)
4274 self.assertAlmostEqual(spin71.r2b[r20_key1], 13.3245678276332, 4)
4275 self.assertAlmostEqual(spin71.r2a[r20_key2], 2.08243621257779, 4)
4276 self.assertAlmostEqual(spin71.r2b[r20_key2], 153.355765094575, 4)
4277 self.assertAlmostEqual(spin71.pA, 0.9665748685124, 4)
4278 self.assertAlmostEqual(spin71.dw, 1.41898001408953, 4)
4279 self.assertAlmostEqual(spin71.kex/1000, 2580.65795560688/1000, 4)
4280 self.assertAlmostEqual(spin71.chi2, 13.4937006732165, 4)
4281
4282
4283 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4284 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4285
4286
4287 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4288 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4289
4290
4292 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site expanded' dispersion model.
4293
4294 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4295 """
4296
4297
4298 self.setup_hansen_cpmg_data(model='NS CPMG 2-site expanded')
4299
4300
4301 spin70 = return_spin(":70")
4302 spin71 = return_spin(":71")
4303
4304
4305 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4306 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4307
4308
4309 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
4310 spin70.pA = 0.9
4311 spin70.dw = 6.0
4312 spin70.kex = 1500.0
4313 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
4314 spin71.pA = 0.9
4315 spin71.dw = 4.0
4316 spin71.kex = 1900.0
4317
4318
4319 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
4320
4321
4322 print("\n\nOptimised parameters:\n")
4323 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4324 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4325 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4326 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4327 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4328 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4329 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4330
4331
4332 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95813330991529, 4)
4333 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39663480561524, 4)
4334 self.assertAlmostEqual(spin70.pA, 0.989700843879574, 4)
4335 self.assertAlmostEqual(spin70.dw, 5.67315878825691, 4)
4336 self.assertAlmostEqual(spin70.kex/1000, 1713.56110716632/1000, 4)
4337 self.assertAlmostEqual(spin70.chi2, 52.5106879242812, 4)
4338
4339
4340 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99881666793312, 4)
4341 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89817482453042, 4)
4342 self.assertAlmostEqual(spin71.pA, 0.986712911453639, 4)
4343 self.assertAlmostEqual(spin71.dw, 2.09273069372236, 4)
4344 self.assertAlmostEqual(spin71.kex/1000, 2438.20525930405/1000, 4)
4345 self.assertAlmostEqual(spin71.chi2, 15.1644913030633, 4)
4346
4347
4348 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4349 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4350
4351
4352 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4353 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4354
4355
4357 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star' dispersion model.
4358
4359 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4360 """
4361
4362
4363 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star')
4364
4365
4366 spin70 = return_spin(":70")
4367 spin71 = return_spin(":71")
4368
4369
4370 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4371 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4372
4373
4374 spin70.r2 = {r20_key1: 6.996327746, r20_key2: 9.452051268}
4375 spin70.pA = 0.9897519798
4376 spin70.dw = 5.644862195
4377 spin70.kex = 1723.820567
4378 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
4379 spin71.pA = 0.9968032899
4380 spin71.dw = 4.577891393
4381 spin71.kex = 1830.044597
4382
4383
4384 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4385
4386
4387 print("\n\nOptimised parameters:\n")
4388 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4389 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4390 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4391 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4392 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4393 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4394 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4395
4396
4397 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95543947938561, 1)
4398 self.assertAlmostEqual(spin70.r2[r20_key2], 9.38991914134929, 1)
4399 self.assertAlmostEqual(spin70.pA, 0.989702750971153, 3)
4400 self.assertAlmostEqual(spin70.dw, 5.67527122494516, 1)
4401 self.assertAlmostEqual(spin70.kex/1000, 1715.72032391817/1000, 1)
4402 self.assertAlmostEqual(spin70.chi2, 52.5011991483842, 1)
4403
4404
4405 self.assertAlmostEqual(spin71.r2[r20_key1], 4.992594256544, 1)
4406 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 2)
4407 self.assertAlmostEqual(spin71.dw/100, 2.09292495350993/100, 2)
4408 self.assertAlmostEqual(spin71.kex/100000, 2438.04423541463/100000, 2)
4409 self.assertAlmostEqual(spin71.chi2/100, 15.1644902423334/100, 1)
4410
4411
4412 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4413 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4414
4415
4416 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4417 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4418
4419
4421 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star full' dispersion model.
4422
4423 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4424 """
4425
4426
4427 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star full')
4428
4429
4430 spin70 = return_spin(":70")
4431 spin71 = return_spin(":71")
4432
4433
4434 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4435 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4436
4437
4438 spin70.r2a = {r20_key1: 6.44836878645126, r20_key2: 7.00382877393494}
4439 spin70.r2b = {r20_key1: 12.2083127421994, r20_key2: 199.862962628402}
4440 spin70.pA = 0.987648082613451
4441 spin70.dw = 5.30679853807572
4442 spin70.kex = 2033.25380420666
4443 spin71.r2a = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
4444 spin71.r2b = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
4445 spin71.pA = 0.992258541625787
4446 spin71.dw = 2.75140650899058
4447 spin71.kex = 2106.60885247431
4448
4449
4450 self.interpreter.minimise.calculate()
4451
4452
4453 self.assertAlmostEqual(spin70.chi2/10, 45.773987568491123/10, 2)
4454 self.assertAlmostEqual(spin71.chi2/10, 17.329385665659192/10, 2)
4455
4456
4598
4599
4601 """Optimisation of the Korzhnev et al., 2005 15N DQ CPMG data using the 'NS MMQ 2-site' model.
4602
4603 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4604
4605 Here only the 15N DQ data will be optimised. The values found by cpmg_fit using just this data are:
4606
4607 - r2 = {'500': 9.487269007171426, '600': 11.718267257562591, '800': 13.624551743116887},
4608 - pA = 0.965402506690231,
4609 - dw = 0.805197170133360,
4610 - dwH = -0.595536627771890,
4611 - kex = 569.003663067619868,
4612 - chi2 = 9.297671357952812.
4613 """
4614
4615
4616 self.setup_korzhnev_2005_data(data_list=['DQ'])
4617
4618
4619 spin = return_spin(":9@N")
4620
4621
4622 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
4623 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
4624 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
4625
4626
4627 spin.r2 = {r20_key1: 9.48527908326952, r20_key2: 11.7135951595536, r20_key3: 13.6153887849344}
4628 spin.pA = 0.965638501551899
4629 spin.dw = 2.8537583461577
4630 spin.dwH = -0.387633062766635
4631 spin.kex = 573.704033851592
4632
4633
4634 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
4635
4636
4637 self.interpreter.monte_carlo.setup(number=2)
4638 self.interpreter.monte_carlo.create_data(method='back_calc')
4639 self.interpreter.monte_carlo.initial_values()
4640 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4641 self.interpreter.monte_carlo.error_analysis()
4642
4643
4644 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4645
4646
4647 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
4648
4649
4650 print("\n\nOptimised parameters:\n")
4651 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
4652 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
4653 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
4654 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
4655 print("%-20s %20.15g" % ("pA", spin.pA))
4656 print("%-20s %20.15g" % ("dw", spin.dw))
4657 print("%-20s %20.15g" % ("dwH", spin.dwH))
4658 print("%-20s %20.15g" % ("kex", spin.kex))
4659 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
4660
4661
4662 self.assertAlmostEqual(spin.r2[r20_key1], 9.48527908326952, 2)
4663 self.assertAlmostEqual(spin.r2[r20_key2], 11.7135951595536, 2)
4664 self.assertAlmostEqual(spin.r2[r20_key3], 13.6153887849344, 2)
4665 self.assertAlmostEqual(spin.pA, 0.965638501551899, 4)
4666 self.assertAlmostEqual(spin.dw, 2.8537583461577, 1)
4667 self.assertAlmostEqual(spin.dwH, -0.387633062766635, 2)
4668 self.assertAlmostEqual(spin.kex/1000, 573.704033851592/1000, 3)
4669 self.assertAlmostEqual(spin.chi2, 9.29563496654824, 2)
4670
4671
4673 """Optimisation of the Korzhnev et al., 2005 15N MQ CPMG data using the 'NS MMQ 2-site' model.
4674
4675 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4676
4677 Here only the 15N MQ data will be optimised. The values found by cpmg_fit using just this data are:
4678
4679 - r2 = {'500': 5.993083514798655, '600': 6.622184438384841, '800': 8.640765919352019},
4680 - pA = 0.930027999814003,
4681 - dw = 4.338620619954370,
4682 - dwH = -0.274250775560818,
4683 - kex = 344.613362916544475,
4684 - chi2 = 10.367733168217050.
4685 """
4686
4687
4688 self.setup_korzhnev_2005_data(data_list=['MQ'])
4689
4690
4691 spin = return_spin(":9@N")
4692
4693
4694 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
4695 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
4696 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
4697
4698
4699 spin.r2 = {r20_key1: 6.02016436619016, r20_key2: 6.65421500772308, r20_key3: 8.6729591487622}
4700 spin.pA = 0.930083249288083
4701 spin.dw = 4.33890689462363
4702 spin.dwH = -0.274316585638047
4703 spin.kex = 344.329651956132
4704
4705
4706 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
4707
4708
4709 self.interpreter.monte_carlo.setup(number=2)
4710 self.interpreter.monte_carlo.create_data(method='back_calc')
4711 self.interpreter.monte_carlo.initial_values()
4712 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4713 self.interpreter.monte_carlo.error_analysis()
4714
4715
4716 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4717
4718
4719 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
4720
4721
4722 print("\n\nOptimised parameters:\n")
4723 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
4724 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
4725 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
4726 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
4727 print("%-20s %20.15g" % ("pA", spin.pA))
4728 print("%-20s %20.15g" % ("dw", spin.dw))
4729 print("%-20s %20.15g" % ("dwH", spin.dwH))
4730 print("%-20s %20.15g" % ("kex", spin.kex))
4731 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
4732
4733
4734 self.assertAlmostEqual(spin.r2[r20_key1], 6.02016436619016, 1)
4735 self.assertAlmostEqual(spin.r2[r20_key2], 6.65421500772308, 1)
4736 self.assertAlmostEqual(spin.r2[r20_key3], 8.6729591487622, 1)
4737 self.assertAlmostEqual(spin.pA, 0.930083249288083, 3)
4738 self.assertAlmostEqual(spin.dw, 4.33890689462363, 2)
4739 self.assertAlmostEqual(spin.dwH, -0.274316585638047, 3)
4740 self.assertAlmostEqual(spin.kex/1000, 344.329651956132/1000, 3)
4741 self.assertAlmostEqual(spin.chi2, 10.3654315659173, 2)
4742
4743
4745 """Optimisation of the Korzhnev et al., 2005 15N SQ CPMG data using the 'NS MMQ 2-site' model.
4746
4747 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4748
4749 Here only the 15N SQ data will be optimised. The values found by cpmg_fit using just this data are:
4750
4751 - r2 = {'500': 8.335037972570017, '600': 8.761366016417508, '800': 10.225001019091822},
4752 - pA = 0.950003458294991,
4753 - dw = 4.358402855315123,
4754 - kex = 429.906473361926999,
4755 - chi2 = 17.393331915567252.
4756 """
4757
4758
4759 self.setup_korzhnev_2005_data(data_list=['SQ'])
4760
4761
4762 spin = return_spin(":9@N")
4763
4764
4765 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4766 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
4767 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4768
4769
4770 spin.r2 = {r20_key1: 8.334232330326190, r20_key2: 8.756773997879968, r20_key3: 10.219320492033058}
4771 spin.pA = 0.950310172115387
4772 spin.dw = 4.356737157889636
4773 spin.kex = 433.176323890829849
4774
4775
4776 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
4777
4778
4779 self.interpreter.monte_carlo.setup(number=2)
4780 self.interpreter.monte_carlo.create_data(method='back_calc')
4781 self.interpreter.monte_carlo.initial_values()
4782 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4783 self.interpreter.monte_carlo.error_analysis()
4784
4785
4786 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4787
4788
4789 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
4790
4791
4792 print("\n\nOptimised parameters:\n")
4793 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
4794 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
4795 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
4796 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
4797 print("%-20s %20.15g" % ("pA", spin.pA))
4798 print("%-20s %20.15g" % ("dw", spin.dw))
4799 print("%-20s %20.15g" % ("kex", spin.kex))
4800 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
4801
4802
4803 self.assertAlmostEqual(spin.r2[r20_key1], 8.334232330326190, 2)
4804 self.assertAlmostEqual(spin.r2[r20_key2], 8.756773997879968, 2)
4805 self.assertAlmostEqual(spin.r2[r20_key3], 10.219320492033058, 1)
4806 self.assertAlmostEqual(spin.pA, 0.950310172115387, 3)
4807 self.assertAlmostEqual(spin.dw, 4.356737157889636, 2)
4808 self.assertAlmostEqual(spin.kex/1000, 433.176323890829849/1000, 2)
4809 self.assertAlmostEqual(spin.chi2, 17.37460582872912, 1)
4810
4811
4813 """Optimisation of the Korzhnev et al., 2005 15N ZQ CPMG data using the 'NS MMQ 2-site' model.
4814
4815 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4816
4817 Here only the 15N ZQ data will be optimised. The values found by cpmg_fit using just this data are:
4818
4819 - r2 = {'500': 5.909812628572937, '600': 6.663690132557320, '800': 6.787171647689906},
4820 - pA = 0.942452612380140,
4821 - dw = 0.858972784230892,
4822 - dwH = 0.087155962730608,
4823 - kex = 373.219151384798920,
4824 - chi2 = 23.863208106025152.
4825 """
4826
4827
4828 self.setup_korzhnev_2005_data(data_list=['ZQ'])
4829
4830
4831 spin = return_spin(":9@N")
4832
4833
4834 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
4835 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
4836 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
4837
4838
4839 spin.r2 = {r20_key1: 5.91033272691614, r20_key2: 6.66368695342258, r20_key3: 6.78922219135537}
4840 spin.pA = 0.942457332074014
4841 spin.dw = 0.850592422908884
4842 spin.dwH = 0.0881272284455416
4843 spin.kex = 372.745483351305
4844
4845
4846 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
4847
4848
4849 self.interpreter.monte_carlo.setup(number=2)
4850 self.interpreter.monte_carlo.create_data(method='back_calc')
4851 self.interpreter.monte_carlo.initial_values()
4852 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4853 self.interpreter.monte_carlo.error_analysis()
4854
4855
4856 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4857
4858
4859 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
4860
4861
4862 print("\n\nOptimised parameters:\n")
4863 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
4864 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
4865 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
4866 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
4867 print("%-20s %20.15g" % ("pA", spin.pA))
4868 print("%-20s %20.15g" % ("dw", spin.dw))
4869 print("%-20s %20.15g" % ("dwH", spin.dwH))
4870 print("%-20s %20.15g" % ("kex", spin.kex))
4871 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
4872
4873
4874 self.assertAlmostEqual(spin.r2[r20_key1], 5.91033272691614, 2)
4875 self.assertAlmostEqual(spin.r2[r20_key2], 6.66368695342258, 2)
4876 self.assertAlmostEqual(spin.r2[r20_key3], 6.78922219135537, 2)
4877 self.assertAlmostEqual(spin.pA, 0.942457332074014, 4)
4878 self.assertAlmostEqual(spin.dw, 0.850592422908884, 1)
4879 self.assertAlmostEqual(spin.dwH, 0.0881272284455416, 2)
4880 self.assertAlmostEqual(spin.kex/1000, 372.745483351305/1000, 3)
4881 self.assertAlmostEqual(spin.chi2, 23.8464637019392, 1)
4882
4883
4885 """Optimisation of the Korzhnev et al., 2005 1H MQ CPMG data using the 'NS MMQ 2-site' model.
4886
4887 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4888
4889 Here only the 1H MQ data will be optimised. The values found by cpmg_fit using just this data are:
4890
4891 - r2 = {'500': -0.000016676911302, '600': 0.036594127620440, '800': 2.131014839635728},
4892 - pA = 0.936911090448340,
4893 - dw = 4.325314846914845,
4894 - dwH = -0.213870168665628,
4895 - kex = 487.361914835074117,
4896 - chi2 = 14.870371897291138.
4897 """
4898
4899
4900 self.setup_korzhnev_2005_data(data_list=['1H MQ'])
4901
4902
4903 spin = return_spin(":9@N")
4904
4905
4906 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
4907 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
4908 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
4909
4910
4911 spin.r2 = {r20_key1: 0.000022585022901, r20_key2: 0.039223196112941, r20_key3: 2.136576686700357}
4912 spin.pA = 0.936884348941701
4913 spin.dw = 4.326454531583964
4914 spin.dwH = -0.214026093221782
4915 spin.kex = 487.043592705469223
4916
4917
4918 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=100)
4919
4920
4921 self.interpreter.monte_carlo.setup(number=2)
4922 self.interpreter.monte_carlo.create_data(method='back_calc')
4923 self.interpreter.monte_carlo.initial_values()
4924 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4925 self.interpreter.monte_carlo.error_analysis()
4926
4927
4928 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4929
4930
4931 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
4932
4933
4934 print("\n\nOptimised parameters:\n")
4935 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
4936 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
4937 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
4938 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
4939 print("%-20s %20.15g" % ("pA", spin.pA))
4940 print("%-20s %20.15g" % ("dw", spin.dw))
4941 print("%-20s %20.15g" % ("dwH", spin.dwH))
4942 print("%-20s %20.15g" % ("kex", spin.kex))
4943 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
4944
4945
4946 self.assertAlmostEqual(spin.r2[r20_key1], 0.000023714274046, 4)
4947 self.assertAlmostEqual(spin.r2[r20_key2], 0.039223196112941, 2)
4948 self.assertAlmostEqual(spin.r2[r20_key3], 2.13657668670036, 2)
4949 self.assertAlmostEqual(spin.pA, 0.936884348941701, 4)
4950 self.assertAlmostEqual(spin.dw, 4.32645453158396, 2)
4951 self.assertAlmostEqual(spin.dwH, -0.214026093221782, 2)
4952 self.assertAlmostEqual(spin.kex/1000, 487.043592705469/1000, 4)
4953 self.assertAlmostEqual(spin.chi2, 14.8642315375301, 2)
4954
4955
4957 """Optimisation of the Korzhnev et al., 2005 1H SQ CPMG data using the 'NS MMQ 2-site' model.
4958
4959 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
4960
4961 Here only the 1H SQ data will be optimised. The values found by cpmg_fit using just this data are:
4962
4963 - r2 = {'500': 6.691697587650816, '600': 6.998915158708793, '800': 5.519267837559072},
4964 - pA = 0.946949480545876,
4965 - dwH = -0.265279672133308,
4966 - kex = 406.548178869750700,
4967 - chi2 = 50.400680290545026.
4968 """
4969
4970
4971 self.setup_korzhnev_2005_data(data_list=['1H SQ'])
4972
4973
4974 spin = return_spin(":9@N")
4975
4976
4977 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
4978 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
4979 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
4980
4981
4982 spin.r2 = {r20_key1: 6.69107911078939, r20_key2: 6.99888898689085, r20_key3: 5.52012880268077}
4983 spin.pA = 0.946990967372467
4984 spin.dwH = -0.265308128403529
4985 spin.kex = 406.843250675648
4986
4987
4988 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
4989
4990
4991 self.interpreter.monte_carlo.setup(number=2)
4992 self.interpreter.monte_carlo.create_data(method='back_calc')
4993 self.interpreter.monte_carlo.initial_values()
4994 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
4995 self.interpreter.monte_carlo.error_analysis()
4996
4997
4998 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
4999
5000
5001 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5002
5003
5004 print("\n\nOptimised parameters:\n")
5005 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5006 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5007 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5008 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5009 print("%-20s %20.15g" % ("pA", spin.pA))
5010 print("%-20s %20.15g" % ("dwH", spin.dwH))
5011 print("%-20s %20.15g" % ("kex", spin.kex))
5012 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5013
5014
5015 self.assertAlmostEqual(spin.r2[r20_key1], 6.69107911078939, 2)
5016 self.assertAlmostEqual(spin.r2[r20_key2], 6.99888898689085, 2)
5017 self.assertAlmostEqual(spin.r2[r20_key3], 5.52012880268077, 2)
5018 self.assertAlmostEqual(spin.pA, 0.946990967372467, 4)
5019 self.assertAlmostEqual(spin.dwH, -0.265308128403529, 3)
5020 self.assertAlmostEqual(spin.kex/1000, 406.843250675648/1000, 2)
5021 self.assertAlmostEqual(spin.chi2, 50.3431330819767, 1)
5022
5023
5025 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model.
5026
5027 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5028
5029 Here all data will be optimised. The values found by cpmg_fit using just this data are:
5030
5031 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596,
5032 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709,
5033 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030,
5034 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627,
5035 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979,
5036 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118},
5037 - pA = 0.943125351763911,
5038 - dw = 4.421827493809807,
5039 - dwH = -0.272637034755752,
5040 - kex = 360.609744568697238,
5041 - chi2 = 162.589570340050813.
5042 """
5043
5044
5045 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ'])
5046
5047
5048 spin = return_spin(":9@N")
5049
5050
5051 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
5052 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
5053 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
5054 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5055 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
5056 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5057 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
5058 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
5059 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
5060 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
5061 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
5062 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
5063 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
5064 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
5065 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
5066 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
5067 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5068 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5069
5070
5071 spin.r2 = {
5072 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704,
5073 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930,
5074 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265,
5075 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090,
5076 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380,
5077 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750
5078 }
5079 spin.pA = 0.943129019477673
5080 spin.dw = 4.42209952545181
5081 spin.dwH = -0.27258970590969
5082 spin.kex = 360.516132791038
5083
5084
5085 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=10)
5086
5087
5088 self.interpreter.monte_carlo.setup(number=2)
5089 self.interpreter.monte_carlo.create_data(method='back_calc')
5090 self.interpreter.monte_carlo.initial_values()
5091 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5092 self.interpreter.monte_carlo.error_analysis()
5093
5094
5095 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5096
5097
5098 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5099
5100
5101 print("\n\nOptimised parameters:\n")
5102 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5103 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1]))
5104 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2]))
5105 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3]))
5106 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4]))
5107 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5]))
5108 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6]))
5109 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7]))
5110 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8]))
5111 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9]))
5112 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10]))
5113 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11]))
5114 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12]))
5115 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13]))
5116 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14]))
5117 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15]))
5118 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16]))
5119 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17]))
5120 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18]))
5121 print("%-20s %20.15g" % ("pA", spin.pA))
5122 print("%-20s %20.15g" % ("dw", spin.dw))
5123 print("%-20s %20.15g" % ("dwH", spin.dwH))
5124 print("%-20s %20.15g" % ("kex", spin.kex))
5125 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5126
5127
5128 self.assertAlmostEqual(spin.r2[r20_key1], 6.67288025927458, 4)
5129 self.assertAlmostEqual(spin.r2[r20_key2], 6.98951408255098, 4)
5130 self.assertAlmostEqual(spin.r2[r20_key3], 5.52959273852704, 4)
5131 self.assertAlmostEqual(spin.r2[r20_key4], 8.39471048876782, 4)
5132 self.assertAlmostEqual(spin.r2[r20_key5], 8.89290699178799, 4)
5133 self.assertAlmostEqual(spin.r2[r20_key6], 10.4077068723693, 4)
5134 self.assertAlmostEqual(spin.r2[r20_key7], 5.93611174376373, 4)
5135 self.assertAlmostEqual(spin.r2[r20_key8], 6.71735669582514, 4)
5136 self.assertAlmostEqual(spin.r2[r20_key9], 6.83835225518265, 4)
5137 self.assertAlmostEqual(spin.r2[r20_key10], 8.59615074668922, 4)
5138 self.assertAlmostEqual(spin.r2[r20_key11], 10.6512137889291, 4)
5139 self.assertAlmostEqual(spin.r2[r20_key12], 12.5710822919109, 4)
5140 self.assertAlmostEqual(spin.r2[r20_key13], 7.85956711501608, 4)
5141 self.assertAlmostEqual(spin.r2[r20_key14], 8.41891642907918, 4)
5142 self.assertAlmostEqual(spin.r2[r20_key15], 11.2362089223038, 4)
5143 self.assertAlmostEqual(spin.r2[r20_key16], 9.1965486378935, 4)
5144 self.assertAlmostEqual(spin.r2[r20_key17], 9.86031627358462, 4)
5145 self.assertAlmostEqual(spin.r2[r20_key18], 11.9752375592575, 4)
5146 self.assertAlmostEqual(spin.pA, 0.943129019477673, 4)
5147 self.assertAlmostEqual(spin.dw, 4.42209952545181, 4)
5148 self.assertAlmostEqual(spin.dwH, -0.27258970590969, 4)
5149 self.assertAlmostEqual(spin.kex/1000, 360.516132791038/1000, 4)
5150 self.assertAlmostEqual(spin.chi2/1000, 162.511988511609/1000, 3)
5151
5152
5154 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model.
5155
5156 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5157
5158 Here all data will be optimised. The values found by cpmg_fit using just this data are:
5159
5160 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596,
5161 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709,
5162 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030,
5163 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627,
5164 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979,
5165 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118},
5166 - pA = 0.943125351763911,
5167 - dw = 4.421827493809807,
5168 - dwH = -0.272637034755752,
5169 - kex = 360.609744568697238,
5170 - chi2 = 162.589570340050813.
5171 """
5172
5173
5174 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ'])
5175
5176
5177 spin = return_spin(":9@N")
5178
5179
5180 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
5181 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
5182 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
5183 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5184 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
5185 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5186 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
5187 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
5188 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
5189 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
5190 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
5191 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
5192 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
5193 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
5194 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
5195 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
5196 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5197 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5198
5199
5200 spin.r2 = {
5201 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704,
5202 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930,
5203 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265,
5204 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090,
5205 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380,
5206 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750
5207 }
5208 spin.pA = 0.943129019477673
5209 spin.dw = 4.42209952545181
5210 spin.dwH = -0.27258970590969
5211 spin.kex = 360.516132791038
5212
5213
5214 self.interpreter.minimise.calculate(verbosity=1)
5215
5216
5217 print("\n\nOptimised parameters:\n")
5218 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5219 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1]))
5220 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2]))
5221 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3]))
5222 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4]))
5223 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5]))
5224 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6]))
5225 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7]))
5226 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8]))
5227 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9]))
5228 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10]))
5229 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11]))
5230 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12]))
5231 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13]))
5232 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14]))
5233 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15]))
5234 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16]))
5235 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17]))
5236 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18]))
5237 print("%-20s %20.15g" % ("pA", spin.pA))
5238 print("%-20s %20.15g" % ("dw", spin.dw))
5239 print("%-20s %20.15g" % ("dwH", spin.dwH))
5240 print("%-20s %20.15g" % ("kex", spin.kex))
5241 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5242
5243
5244 self.assertAlmostEqual(spin.chi2/1000, 162.511988511609/1000, 3)
5245
5246
5248 """Check of all possible dispersion graphs from optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5249
5250 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5251
5252 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5253
5254 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5255 - 0.483 0.89623903 2.4503699912708878
5256 - 0.545 1.1694838
5257 - 0.545 1.1761503
5258 - 0.622 1.294
5259 - 0.669 1.5176493
5260 - 0.722 1.6238791
5261 - 0.813 1.9395758
5262 - 1.011 2.3558415 10.547000429321157
5263 """
5264
5265
5266 model = 'TSMFK01'
5267 expfolder = "acbp_cpmg_disp_048MGuHCl_40C_041223"
5268 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model=model, expfolder=expfolder)
5269
5270
5271 res61L = cdp.mol[0].res[0].spin[0]
5272
5273
5274 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5275
5276
5277 res61L.r2a = {r20_key1: 8.0}
5278 res61L.dw = 6.5
5279 res61L.k_AB = 2.5
5280
5281
5282 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5283
5284
5285 y_axis_types = [Y_AXIS_R2_EFF, Y_AXIS_R2_R1RHO]
5286 x_axis_types = [X_AXIS_DISP, X_AXIS_THETA, X_AXIS_W_EFF]
5287 interpolate_types = [INTERPOLATE_DISP]
5288
5289
5290 result_dir_name = ds.tmpdir
5291 result_folders = [model]
5292 spin_id = ":61@N"
5293
5294
5295 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+expfolder+sep+'check_graphs'
5296
5297 for result_folder in result_folders:
5298 for y_axis in y_axis_types:
5299 for x_axis in x_axis_types:
5300 for interpolate in interpolate_types:
5301
5302 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
5303
5304
5305 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
5306
5307
5308 dir = result_dir_name+sep+result_folder
5309 print("Plotting combination of %s, %s, %s"%(y_axis, x_axis, interpolate))
5310 self.interpreter.relax_disp.plot_disp_curves(dir=dir, y_axis=y_axis, x_axis=x_axis, interpolate=interpolate, force=True)
5311
5312
5313 file_path = get_file_path(file_name, dir)
5314
5315
5316 print("Testing file access to graph: %s"%file_path)
5317 self.assert_(access(file_path, F_OK))
5318
5319
5320 file_prod = open(file_path)
5321 lines_prod = file_prod.readlines()
5322 file_prod.close()
5323
5324
5325 dir_comp = data_path+sep+result_folder
5326 file_path_comp = get_file_path(file_name, dir_comp)
5327 file_comp = open(file_path_comp)
5328 lines_comp = file_comp.readlines()
5329 file_comp.close()
5330
5331
5332 self.assertEqual(len(lines_prod), len(lines_comp))
5333 for j in range(len(lines_prod)):
5334
5335 first_char = lines_prod[j][0]
5336 if first_char in ["@", "&"]:
5337 self.assertEqual(lines_prod[j], lines_comp[j])
5338 else:
5339
5340
5341 x_prod, y_prod, y_prod_err = lines_prod[j].split()
5342 x_comp, y_comp, y_comp_err = lines_comp[j].split()
5343 self.assertAlmostEqual(float(x_prod), float(x_comp))
5344 self.assertAlmostEqual(float(y_prod), float(y_comp))
5345 self.assertAlmostEqual(float(y_prod_err), float(y_comp_err))
5346
5347
5349 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5350
5351 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5352 """
5353
5354
5355 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5356
5357
5358 res61L = cdp.mol[0].res[0].spin[0]
5359
5360
5361 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5362
5363
5364 res61L.r2 = {r20_key1: 8.0}
5365 res61L.pA = 0.9
5366 res61L.dw = 6.0
5367 res61L.kex = 600.0
5368
5369
5370 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5371
5372
5373 print("\n\nOptimised parameters:\n")
5374 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5375 print("%-20s %20.15g" % ("R2 (600 MHz)", res61L.r2[r20_key1]))
5376 print("%-20s %20.15g" % ("pA", res61L.pA))
5377 print("%-20s %20.15g" % ("dw", res61L.dw))
5378 print("%-20s %20.15g" % ("kex", res61L.kex))
5379 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5380
5381
5382 self.assertAlmostEqual(res61L.r2[r20_key1], 8.69277980194016, 4)
5383 self.assertAlmostEqual(res61L.pA, 0.9943781590842946, 5)
5384 self.assertAlmostEqual(res61L.dw, 6.389453131263374, 3)
5385 self.assertAlmostEqual(res61L.kex, 609.262167216419, 0)
5386 self.assertAlmostEqual(res61L.chi2, 65.99987828889657, 5)
5387
5388
5389 self.assertEqual(res61L.k_AB, res61L.kex * (1.0 - res61L.pA))
5390
5391
5392 self.assertEqual(res61L.k_BA, res61L.kex * res61L.pA)
5393
5394
5396 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5397
5398 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5399 """
5400
5401
5402 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72 full', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5403
5404
5405 res61L = cdp.mol[0].res[0].spin[0]
5406
5407
5408 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5409
5410
5411 res61L.r2a = {r20_key1: 8.0}
5412 res61L.r2b = {r20_key1: 105.0}
5413 res61L.pA = 0.9
5414 res61L.dw = 6.0
5415 res61L.kex = 500.0
5416
5417
5418 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5419
5420
5421 print("\n\nOptimised parameters:\n")
5422 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5423 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
5424 print("%-20s %20.15g" % ("R2B (600 MHz)", res61L.r2b[r20_key1]))
5425 print("%-20s %20.15g" % ("pA", res61L.pA))
5426 print("%-20s %20.15g" % ("dw", res61L.dw))
5427 print("%-20s %20.15g" % ("kex", res61L.kex))
5428 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5429
5430
5431 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.044428899438309, 0)
5432 self.assertAlmostEqual(res61L.r2b[r20_key1], 105.11894506392449, -2)
5433 self.assertAlmostEqual(res61L.pA, 0.992066883657578, 2)
5434 self.assertAlmostEqual(res61L.dw, 6.389453586338883, 3)
5435 self.assertAlmostEqual(res61L.kex, 513.483608742063, -2)
5436 self.assertAlmostEqual(res61L.chi2, 65.99987828890289, 5)
5437
5438
5440 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5441
5442 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5443
5444 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5445
5446 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5447 - 0.483 0.89623903 2.4503699912708878
5448 - 0.545 1.1694838
5449 - 0.545 1.1761503
5450 - 0.622 1.294
5451 - 0.669 1.5176493
5452 - 0.722 1.6238791
5453 - 0.813 1.9395758
5454 - 1.011 2.3558415 10.547000429321157
5455 """
5456
5457
5458 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5459
5460
5461 res61L = cdp.mol[0].res[0].spin[0]
5462
5463
5464 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5465
5466
5467 res61L.r2a = {r20_key1: 8.0}
5468 res61L.dw = 6.5
5469 res61L.k_AB = 2.5
5470
5471
5472 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5473
5474
5475 print("\n\nOptimised parameters:\n")
5476 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5477 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
5478 print("%-20s %20.15g" % ("dw", res61L.dw))
5479 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
5480 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5481
5482
5483
5484 self.assertAlmostEqual(res61L.k_AB, 2.45, 1)
5485
5486
5488 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5489
5490 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 1.01 M GuHCl (guanidine hydrochloride).
5491
5492 The comparison is to Figure 2, which is for dataset with 1 M GuHCl. The reported results are expected to be in rad.s^-1. Conversion into relax stored values is preferably.
5493
5494 Representative 15N CPMG relaxation dispersion curve measured on the cross peaks from residue L61 in folded ACBP at pH 5.3, 1 M GuHCl, and 40C:
5495
5496 1. The dotted line represents a residue-specific fit of all parameters in Eq. 1:
5497 - k_AB = 11.3 +/- 0.7 s^-1,
5498 - dw = (2.45 +/- 0.09) * 10^3 s^-1,
5499 - R2 = 8.0 +/- 0.5 s^-1.
5500
5501 2. The solid line represents a global fit of k_AB to all protein residues and a residue-specific fit of dw and R2.:
5502 - k_AB = 10.55 +/- 0.08 s^-1,
5503 - dw = (2.44 +/- 0.08) * 10^3 s^-1,
5504 - R2 = 8.4 +/- 0.3 s^-1.
5505
5506 Conversion of paper results to relax results is performed by:
5507
5508 - dw(ppm) = dw(rad.s^-1) * 10^6 * 1/(2*pi) * (gyro1H/(gyro15N*spectrometer_freq)) = 2.45E3 * 1E6 / (2 * math.pi) * (26.7522212E7/(-2.7126E7 * 599.8908622E6)) = -6.41 ppm.
5509
5510 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5511
5512 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5513 - 0.483 0.89623903 2.4503699912708878
5514 - 0.545 1.1694838
5515 - 0.545 1.1761503
5516 - 0.622 1.294
5517 - 0.669 1.5176493
5518 - 0.722 1.6238791
5519 - 0.813 1.9395758
5520 - 1.011 2.3558415 10.547000429321157
5521 """
5522
5523
5524 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_101MGuHCl_40C_041223")
5525
5526
5527 res61L = cdp.mol[0].res[0].spin[0]
5528
5529
5530 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086270e6)
5531
5532
5533 res61L.r2a = {r20_key1: 8.0}
5534 res61L.dw = 6.5
5535 res61L.k_AB = 11.0
5536
5537
5538 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5539
5540
5541 print("\n\nOptimised parameters:\n")
5542 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5543 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
5544 print("%-20s %20.15g" % ("dw", res61L.dw))
5545 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
5546 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5547
5548
5549
5550 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.4, 0)
5551 self.assertAlmostEqual(res61L.dw, 6.41, 0)
5552 self.assertAlmostEqual(res61L.k_AB, 10.55, 0)
5553
5554
5556 """Test the 'LM63 3-site' dispersion model using the pure noise-free synthetic data."""
5557
5558
5559 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'lm63_3site'
5560
5561
5562 self.interpreter.reset()
5563 self.interpreter.state.load(data_path+sep+'r2eff_values')
5564
5565
5566 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='LM63 3-site', bundle_to='relax_disp')
5567 self.interpreter.pipe.switch(pipe_name='LM63 3-site')
5568
5569
5570 self.interpreter.relax_disp.select_model(model='LM63 3-site')
5571 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='LM63 3-site', param='r2eff')
5572 self.interpreter.spin.isotope('15N')
5573
5574
5575 spin1 = return_spin(":1")
5576 spin2 = return_spin(":2")
5577
5578
5579 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5580 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5581
5582
5583 spin1.r2 = {r20_key1: 12.0, r20_key2: 12.0}
5584 spin1.phi_ex_B = 0.1
5585 spin1.phi_ex_C = 0.5
5586 spin1.kB = 1500.0
5587 spin1.kC = 2500.0
5588 spin2.r2 = {r20_key1: 15.0, r20_key2: 15.0}
5589 spin2.phi_ex_B = 0.1
5590 spin2.phi_ex_C = 0.5
5591 spin2.kB = 1500.0
5592 spin2.kC = 2500.0
5593
5594
5595 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5596
5597
5598 self.interpreter.monte_carlo.setup(number=3)
5599 self.interpreter.monte_carlo.create_data(method='back_calc')
5600 self.interpreter.monte_carlo.initial_values()
5601 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-2, grad_tol=None, max_iter=10, constraints=True, scaling=True, verbosity=1)
5602 self.interpreter.monte_carlo.error_analysis()
5603
5604
5605 self.interpreter.results.write(file='devnull', compress_type=1, force=True)
5606
5607
5608 print("\n\nOptimised parameters:\n")
5609 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
5610 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
5611 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
5612 print("%-20s %20.15g %20.15g" % ("phi_ex_B", spin1.phi_ex_B, spin2.phi_ex_B))
5613 print("%-20s %20.15g %20.15g" % ("phi_ex_C", spin1.phi_ex_C, spin2.phi_ex_C))
5614 print("%-20s %20.15g %20.15g" % ("kB", spin1.kB, spin2.kB))
5615 print("%-20s %20.15g %20.15g" % ("kC", spin1.kC, spin2.kC))
5616 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
5617 self.assertAlmostEqual(spin1.r2[r20_key1], 12.0, 2)
5618 self.assertAlmostEqual(spin1.r2[r20_key2], 12.0, 2)
5619 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
5620 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
5621 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
5622 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
5623 self.assertAlmostEqual(spin1.chi2, 0.0, 3)
5624 self.assertAlmostEqual(spin2.r2[r20_key1], 15.0, 3)
5625 self.assertAlmostEqual(spin2.r2[r20_key2], 15.0, 3)
5626 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
5627 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
5628 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
5629 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
5630 self.assertAlmostEqual(spin2.chi2, 0.0, 3)
5631
5632
5634 """Test the relaxation dispersion 'M61' model curve fitting to fixed time synthetic data."""
5635
5636
5637 ds.fixed = True
5638
5639
5640 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py')
5641
5642
5643 i0 = [100000.0, 20000.0]
5644 r1rho_prime = [2.25, 24.0]
5645 pA = 0.7
5646 kex = 1000.0
5647 delta_omega = [1.0, 2.0]
5648 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000']
5649 phi_ex = []
5650 for i in range(2):
5651 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
5652 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]]
5653
5654
5655 self.interpreter.pipe.switch('R2eff - relax_disp')
5656 spin_index = 0
5657 for spin, spin_id in spin_loop(return_id=True):
5658
5659 print("\nSpin %s." % spin_id)
5660
5661
5662 for i in range(len(keys)):
5663 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
5664
5665
5666 spin_index += 1
5667
5668
5669 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5670
5671
5672 self.interpreter.pipe.switch('M61 - relax_disp')
5673 spin_index = 0
5674 for spin, spin_id in spin_loop(return_id=True):
5675
5676 print("\nSpin %s." % spin_id)
5677
5678
5679 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
5680 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
5681 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
5682
5683
5684 spin_index += 1
5685
5686
5688 """Test the relaxation dispersion 'M61' model curve fitting to the full exponential synthetic data."""
5689
5690
5691 ds.fixed = False
5692
5693
5694 ds.single = True
5695
5696
5697 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py')
5698
5699
5700 i0 = [100000.0, 20000.0]
5701 r1rho_prime = [2.25, 24.0]
5702 pA = 0.7
5703 kex = 1000.0
5704 delta_omega = [1.0, 2.0]
5705 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000']
5706 phi_ex = []
5707 for i in range(2):
5708 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
5709 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]]
5710
5711
5712 self.interpreter.pipe.switch('R2eff - relax_disp')
5713 spin_index = 0
5714 for spin, spin_id in spin_loop(return_id=True):
5715
5716 print("\nSpin %s." % spin_id)
5717
5718
5719 for i in range(len(keys)):
5720 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
5721
5722
5723 spin_index += 1
5724
5725
5726 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5727
5728
5729 self.interpreter.pipe.switch('M61 - relax_disp')
5730 spin_index = 0
5731 for spin, spin_id in spin_loop(return_id=True):
5732
5733 print("\nSpin %s." % spin_id)
5734
5735
5736 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
5737 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
5738 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
5739
5740
5741 spin_index += 1
5742
5743
5745 """Test the relaxation dispersion 'M61 skew' model curve fitting to fixed time synthetic data."""
5746
5747
5748 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61b.py')
5749
5750
5751 i0 = [100000.0, 20000.0]
5752 r1rho_prime = [10.0, 24.0]
5753 pA = 0.95
5754 kex = 2000.0
5755 delta_omega = [1.0, 2.0]
5756
5757
5758 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5759
5760
5761 self.interpreter.pipe.switch("%s - relax_disp" % MODEL_M61B)
5762 spin_index = 0
5763 for spin, spin_id in spin_loop(return_id=True):
5764
5765 print("\nSpin %s." % spin_id)
5766
5767
5768 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
5769 self.assertAlmostEqual(spin.pA, pA, 2)
5770 self.assertAlmostEqual(spin.dw, dw[spin_index], 2)
5771 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
5772
5773
5774 spin_index += 1
5775
5776
5778 """Test that all models which can nest, have all their parameters converted."""
5779
5780
5781 cdp.exp_type_list = EXP_TYPE_LIST
5782
5783
5784 all_models_info = models_info(models=MODEL_LIST_FULL)
5785
5786
5787 print("Printing the listed of nested models for each model.")
5788 print("#########################################")
5789 for model_info in all_models_info:
5790 print("%s"%model_info.model),
5791 print("<-"),
5792 nest_list = model_info.nest_list
5793 if nest_list == None:
5794 nest_list = ["None"]
5795 print(', '.join(map(str, nest_list)))
5796
5797
5798 if nest_list == ["None"]:
5799 continue
5800
5801
5802 model_params = model_info.params
5803
5804
5805 for nested_model in nest_list:
5806
5807 nested_model_params = MODEL_PARAMS[nested_model]
5808
5809
5810 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params)
5811
5812
5813 self.assertEqual(len(par_dic), len(model_params))
5814
5815
5816 for param, param_conv in par_dic.iteritems():
5817 if param != param_conv:
5818 print("Model:'%s', Nested model:'%s', Copying '%s' to '%s'." % (model_info.model, nested_model, param_conv, param))
5819 self.assertNotEqual(param_conv, None)
5820
5821
5823 """Compare the 'NS MMQ 3-site' dispersion model to synthetic data from cpmg_fit."""
5824
5825
5826 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site.py')
5827
5828
5829 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
5830
5831
5833 """Compare the 'NS MMQ 3-site linear' dispersion model to synthetic data from cpmg_fit."""
5834
5835
5836 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site_linear.py')
5837
5838
5839 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
5840
5841
5843 """Compare the 'NS R1rho 3-site' dispersion model to synthetic data from cpmg_fit."""
5844
5845
5846 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site.py')
5847
5848
5849 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 136.13141468674999, 3)
5850
5851
5853 """Compare the 'NS R1rho 3-site linear' dispersion model to synthetic data from cpmg_fit."""
5854
5855
5856 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site_linear.py')
5857
5858
5859 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 0.030959849811015544, 3)
5860
5861
5863 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
5864
5865 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
5866
5867 This uses the automatic analysis.
5868
5869 """
5870
5871
5872 cluster_ids = [
5873 ":13@N",
5874 ":15@N",
5875 ":16@N",
5876 ":25@N",
5877 ":26@N",
5878 ":28@N",
5879 ":39@N",
5880 ":40@N",
5881 ":41@N",
5882 ":43@N",
5883 ":44@N",
5884 ":45@N",
5885 ":49@N",
5886 ":52@N",
5887 ":53@N"]
5888
5889
5890 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids)
5891
5892
5893 self.assertEqual(len(cdp.mol), 1)
5894 self.assertEqual(cdp.mol[0].name, None)
5895 self.assertEqual(len(cdp.mol[0].res), 48)
5896
5897
5898 cs = [122.223, 122.162, 114.250, 125.852, 118.626, 117.449, 119.999, 122.610, 118.602, 118.291, 115.393,
5899 121.288, 117.448, 116.378, 116.316, 117.263, 122.211, 118.748, 118.103, 119.421, 119.317, 119.386, 117.279,
5900 122.103, 120.038, 116.698, 111.811, 118.639, 118.285, 121.318, 117.770, 119.948, 119.759, 118.314, 118.160,
5901 121.442, 118.714, 113.080, 125.706, 119.183, 120.966, 122.361, 126.675, 117.069, 120.875, 109.372, 119.811, 126.048]
5902
5903 i = 0
5904 for spin, spin_id in spin_loop(return_id=True):
5905
5906 self.assertEqual(spin.chemical_shift, cs[i])
5907
5908
5909 i += 1
5910
5911
5912 i = 0
5913 j = 0
5914
5915 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
5916 if curspin.select == True:
5917 i += 1
5918 if curspin.select == False:
5919 j += 1
5920
5921
5922 self.assertEqual(i, len(cluster_ids))
5923 self.assertEqual(j, 48-len(cluster_ids))
5924
5925
5926 self.assertEqual(cdp.mol[0].res[7].num, 13)
5927 self.assertEqual(cdp.mol[0].res[7].spin[0].kex, ds.guess[':13@N'][6])
5928 self.assertEqual(cdp.mol[0].res[7].spin[0].ri_data['R1'], ds.ref[':13@N'][2])
5929
5930 self.assertEqual(cdp.mol[0].res[9].num, 15)
5931 self.assertEqual(cdp.mol[0].res[9].spin[0].kex, ds.guess[':15@N'][6])
5932 self.assertEqual(cdp.mol[0].res[9].spin[0].ri_data['R1'], ds.ref[':15@N'][2])
5933
5934 self.assertEqual(cdp.mol[0].res[10].num, 16)
5935 self.assertEqual(cdp.mol[0].res[10].spin[0].kex, ds.guess[':16@N'][6])
5936 self.assert_(hasattr(cdp.mol[0].res[10].spin[0], 'ri_data'))
5937
5938 self.assertEqual(cdp.mol[0].res[16].num, 25)
5939 self.assertEqual(cdp.mol[0].res[16].spin[0].kex, ds.guess[':25@N'][6])
5940 self.assert_(hasattr(cdp.mol[0].res[16].spin[0], 'ri_data'))
5941
5942 self.assertEqual(cdp.mol[0].res[17].num, 26)
5943 self.assertEqual(cdp.mol[0].res[17].spin[0].kex, ds.guess[':26@N'][6])
5944 self.assert_(hasattr(cdp.mol[0].res[17].spin[0], 'ri_data'))
5945
5946 self.assertEqual(cdp.mol[0].res[19].num, 28)
5947 self.assertEqual(cdp.mol[0].res[19].spin[0].kex, ds.guess[':28@N'][6])
5948 self.assert_(hasattr(cdp.mol[0].res[19].spin[0], 'ri_data'))
5949
5950 self.assertEqual(cdp.mol[0].res[29].num, 39)
5951 self.assertEqual(cdp.mol[0].res[29].spin[0].kex, ds.guess[':39@N'][6])
5952 self.assert_(hasattr(cdp.mol[0].res[29].spin[0], 'ri_data'))
5953
5954 self.assertEqual(cdp.mol[0].res[30].num, 40)
5955 self.assertEqual(cdp.mol[0].res[30].spin[0].kex, ds.guess[':40@N'][6])
5956 self.assert_(hasattr(cdp.mol[0].res[30].spin[0], 'ri_data'))
5957
5958 self.assertEqual(cdp.mol[0].res[31].num, 41)
5959 self.assertEqual(cdp.mol[0].res[31].spin[0].kex, ds.guess[':41@N'][6])
5960 self.assert_(hasattr(cdp.mol[0].res[31].spin[0], 'ri_data'))
5961
5962 self.assertEqual(cdp.mol[0].res[33].num, 43)
5963 self.assertEqual(cdp.mol[0].res[33].spin[0].kex, ds.guess[':43@N'][6])
5964 self.assert_(hasattr(cdp.mol[0].res[33].spin[0], 'ri_data'))
5965
5966 self.assertEqual(cdp.mol[0].res[34].num, 44)
5967 self.assertEqual(cdp.mol[0].res[34].spin[0].kex, ds.guess[':44@N'][6])
5968 self.assert_(hasattr(cdp.mol[0].res[34].spin[0], 'ri_data'))
5969
5970 self.assertEqual(cdp.mol[0].res[35].num, 45)
5971 self.assertEqual(cdp.mol[0].res[35].spin[0].kex, ds.guess[':45@N'][6])
5972 self.assert_(hasattr(cdp.mol[0].res[35].spin[0], 'ri_data'))
5973
5974 self.assertEqual(cdp.mol[0].res[38].num, 49)
5975 self.assertEqual(cdp.mol[0].res[38].spin[0].kex, ds.guess[':49@N'][6])
5976 self.assert_(hasattr(cdp.mol[0].res[38].spin[0], 'ri_data'))
5977
5978 self.assertEqual(cdp.mol[0].res[41].num, 52)
5979 self.assertEqual(cdp.mol[0].res[41].spin[0].kex, ds.guess[':52@N'][6])
5980 self.assert_(hasattr(cdp.mol[0].res[41].spin[0], 'ri_data'))
5981
5982 self.assertEqual(cdp.mol[0].res[42].num, 53)
5983 self.assertEqual(cdp.mol[0].res[42].spin[0].kex, ds.guess[':53@N'][6])
5984 self.assert_(hasattr(cdp.mol[0].res[42].spin[0], 'ri_data'))
5985
5986
5987 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
5988
5989
5990 GRID_INC = 4
5991
5992
5993 MC_NUM = 3
5994
5995
5996 MODSEL = 'AIC'
5997
5998
5999
6000 OPT_FUNC_TOL = 1e-1
6001 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
6002 OPT_MAX_ITERATIONS = 1000
6003 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
6004
6005 result_dir_name = ds.tmpdir
6006
6007
6008 for curspin in cluster_ids:
6009 self.interpreter.relax_disp.cluster('free spins', curspin)
6010
6011 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
6012
6013
6014
6015
6016
6017
6018
6019
6020 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
6021
6022
6023
6024 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
6025
6026
6027
6028
6029
6030 print("\n\n################")
6031 print("Printing results")
6032 print("################\n")
6033 for model in MODELS:
6034
6035 if model == MODEL_R2EFF:
6036 continue
6037
6038
6039 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
6040 print("\nModel: %s" % (model))
6041
6042
6043 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6044
6045 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
6046
6047
6048 print("Optimised parameters for spin: %s" % (spin_string))
6049 for param in cur_spin.params + ['chi2']:
6050
6051 if param in ['r1', 'r2']:
6052 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
6053
6054 r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
6055
6056
6057 value = getattr(cur_spin, param)[r20_key]
6058
6059
6060 print("%-10s %-6s %-6s %3.3f" % ("Parameter:", param, "Value:", value))
6061
6062
6063 else:
6064
6065 value = getattr(cur_spin, param)
6066
6067
6068 print("%-10s %-6s %-6s %3.3f" % ("Parameter:", param, "Value:", value))
6069
6070
6071 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % ('final'))
6072 print("\nFinal pipe")
6073
6074
6076 """Check of plot_disp_curves() function, after optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'R2eff' model.
6077
6078 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
6079
6080 This uses the automatic analysis.
6081
6082 """
6083
6084
6085 cluster_ids = [
6086 ":52@N"]
6087
6088
6089 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids)
6090
6091
6092 MODELS = [MODEL_R2EFF]
6093
6094
6095 GRID_INC = 4
6096
6097
6098 MC_NUM = 3
6099
6100
6101 MODSEL = 'AIC'
6102
6103
6104
6105 OPT_FUNC_TOL = 1e-1
6106 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
6107 OPT_MAX_ITERATIONS = 1000
6108 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
6109
6110 result_dir_name = ds.tmpdir
6111
6112
6113 for curspin in cluster_ids:
6114 self.interpreter.relax_disp.cluster('free spins', curspin)
6115
6116 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
6117
6118 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
6119
6120
6121 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
6122
6123
6124 graph_comb = [
6125 [Y_AXIS_R2_EFF, X_AXIS_DISP, INTERPOLATE_DISP],
6126 [Y_AXIS_R2_EFF, X_AXIS_THETA, INTERPOLATE_DISP],
6127 [Y_AXIS_R2_R1RHO, X_AXIS_W_EFF, INTERPOLATE_DISP],
6128 [Y_AXIS_R2_EFF, X_AXIS_THETA, INTERPOLATE_OFFSET]
6129 ]
6130
6131
6132 result_folders = MODELS
6133
6134
6135 spin_id = ':52@N'
6136
6137
6138 for result_folder in result_folders:
6139
6140 if result_folder == MODEL_R2EFF:
6141 continue
6142
6143
6144 for y_axis, x_axis, interpolate in graph_comb:
6145
6146 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
6147
6148
6149 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
6150
6151
6152 file_path = get_file_path(file_name, result_dir_name+sep+result_folder)
6153
6154 print("Testing file access to graph: %s"%file_path)
6155 self.assert_(access(file_path, F_OK))
6156
6157
6158 y_axis_types = [Y_AXIS_R2_EFF, Y_AXIS_R2_R1RHO]
6159 x_axis_types = [X_AXIS_DISP, X_AXIS_THETA, X_AXIS_W_EFF]
6160 interpolate_types = [INTERPOLATE_DISP, INTERPOLATE_OFFSET]
6161
6162 result_dir_name = ds.tmpdir
6163
6164
6165 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep+'check_graphs'
6166
6167 for result_folder in result_folders:
6168
6169 if result_folder == MODEL_R2EFF:
6170 continue
6171
6172 for y_axis in y_axis_types:
6173 for x_axis in x_axis_types:
6174 for interpolate in interpolate_types:
6175
6176 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
6177
6178
6179 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
6180
6181
6182 dir = result_dir_name+sep+result_folder
6183 print("Plotting combination of %s, %s, %s"%(y_axis, x_axis, interpolate))
6184 self.interpreter.relax_disp.plot_disp_curves(dir=dir, y_axis=y_axis, x_axis=x_axis, interpolate=interpolate, force=True)
6185
6186
6187 file_path = get_file_path(file_name, dir)
6188
6189
6190 print("Testing file access to graph: %s"%file_path)
6191 self.assert_(access(file_path, F_OK))
6192
6193
6194 file_prod = open(file_path)
6195 lines_prod = file_prod.readlines()
6196 file_prod.close()
6197
6198
6199 dir_comp = data_path+sep+result_folder
6200 file_path_comp = get_file_path(file_name, dir_comp)
6201 file_comp = open(file_path_comp)
6202 lines_comp = file_comp.readlines()
6203 file_comp.close()
6204
6205
6206 self.assertEqual(len(lines_prod), len(lines_comp))
6207 for j in range(len(lines_prod)):
6208
6209 first_char = lines_prod[j][0]
6210 if first_char in ["@", "&"]:
6211 self.assertEqual(lines_prod[j], lines_comp[j])
6212 else:
6213
6214
6215 x_prod, y_prod, y_prod_err = lines_prod[j].split()
6216 x_comp, y_comp, y_comp_err = lines_comp[j].split()
6217 self.assertAlmostEqual(float(x_prod), float(x_comp))
6218 self.assertAlmostEqual(float(y_prod), float(y_comp))
6219
6220
6222 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
6223
6224 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
6225
6226 This uses the automatic analysis, with missing loading R1.
6227
6228 """
6229
6230
6231 cluster_ids = [
6232 ":13@N",
6233 ":15@N",
6234 ":16@N",
6235 ":25@N",
6236 ":26@N",
6237 ":28@N",
6238 ":39@N",
6239 ":40@N",
6240 ":41@N",
6241 ":43@N",
6242 ":44@N",
6243 ":45@N",
6244 ":49@N",
6245 ":52@N",
6246 ":53@N"]
6247
6248
6249 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids, read_R1=False)
6250
6251
6252 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
6253
6254
6255 GRID_INC = None
6256
6257
6258 MC_NUM = 3
6259
6260
6261 MODSEL = 'AIC'
6262
6263
6264
6265 OPT_FUNC_TOL = 1e-25
6266 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
6267 OPT_MAX_ITERATIONS = 10000000
6268 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
6269
6270 result_dir_name = ds.tmpdir
6271
6272
6273 for curspin in cluster_ids:
6274 self.interpreter.relax_disp.cluster('free spins', curspin)
6275
6276 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
6277
6278
6279
6280
6281
6282
6283
6284
6285 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
6286
6287
6288
6289 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000"
6290
6291 r1_fit = True
6292
6293
6294 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, pre_run_dir=prev_data_path, r1_fit=r1_fit)
6295
6296
6297 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='MC2000')
6298
6299
6301 """Test the operation of the relax_disp.r2eff_read user function."""
6302
6303
6304 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'800_MHz'
6305
6306
6307 self.interpreter.sequence.read(file='66.667.in', dir=data_path, res_num_col=1)
6308
6309
6310 id = 'test'
6311
6312
6313 self.interpreter.spectrometer.frequency(id=id, frq=800e6)
6314 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
6315
6316
6317 self.interpreter.relax_disp.r2eff_read(id=id, file='66.667.in', dir=data_path, disp_frq=66.667, res_num_col=1, data_col=2, error_col=3)
6318
6319
6320 data = [
6321 ['cpmg_frqs', {'test': 66.667}],
6322 ['cpmg_frqs_list', [66.667]],
6323 ['dispersion_points', 1],
6324 ['exp_type', {'test': 'SQ CPMG'}],
6325 ['exp_type_list', ['SQ CPMG']],
6326 ['spectrometer_frq', {'test': 800000000.0}],
6327 ['spectrometer_frq_count', 1],
6328 ['spectrometer_frq_list', [800000000.0]],
6329 ['spectrum_ids', ['test']]
6330 ]
6331 for name, value in data:
6332
6333 self.assert_(hasattr(cdp, name))
6334
6335
6336 obj = getattr(cdp, name)
6337 self.assertEqual(obj, value)
6338
6339
6340 data = [
6341 [1, 2.3035747e+04, 8.5467725e+01],
6342 [2, 9.9629762e+04, 2.8322033e+02],
6343 [3, 9.5663137e+04, 2.8632929e+02],
6344 [4, 1.7089893e+05, 3.1089428e+02],
6345 [5, 4.7323876e+04, 1.0084269e+02],
6346 [6, 2.0199122e+04, 1.0135220e+02],
6347 [7, 1.6655488e+05, 3.1609061e+02],
6348 [8, 9.0061074e+04, 1.9176585e+02],
6349 [10, 8.4726204e+04, 2.8898155e+02],
6350 [11, 1.5050233e+05, 4.3138029e+02],
6351 [12, 9.2998531e+04, 3.0440191e+02],
6352 [13, 1.6343507e+05, 3.3144097e+02],
6353 [14, 1.0137301e+05, 3.7314642e+02],
6354 [15, 8.3407837e+04, 1.6546473e+02],
6355 [16, 1.3819126e+05, 3.3388517e+02],
6356 [17, 1.1010490e+05, 3.5639222e+02],
6357 [18, 9.4324035e+04, 3.2343585e+02],
6358 [19, 1.1135179e+05, 3.0706671e+02],
6359 [20, 7.6339410e+04, 1.7377460e+02],
6360 [21, 6.2008453e+04, 1.7327150e+02],
6361 [22, 1.0590404e+05, 2.4814635e+02],
6362 [23, 1.0630198e+05, 2.3601100e+02],
6363 [24, 7.2996320e+04, 1.4952465e+02],
6364 [25, 9.5486742e+04, 2.7080766e+02],
6365 [26, 5.8067989e+04, 1.6820462e+02],
6366 [27, -1.7168510e+04, 2.2519560e+02],
6367 [28, 1.6891473e+05, 2.3497525e+02],
6368 [29, 9.4038555e+04, 2.0357593e+02],
6369 [30, 2.1386951e+04, 2.2153532e+02],
6370 [31, 9.3982899e+04, 2.0937056e+02],
6371 [32, 8.6097484e+04, 2.3868467e+02],
6372 [33, 1.0194337e+05, 2.7370704e+02],
6373 [34, 8.5683111e+04, 2.0838076e+02],
6374 [35, 8.6985768e+04, 2.0889310e+02],
6375 [36, 8.6011237e+04, 1.7498390e+02],
6376 [37, 1.0984097e+05, 2.7622998e+02],
6377 [38, 8.7017879e+04, 2.6547994e+02],
6378 [39, 9.1682649e+04, 5.2777676e+02],
6379 [40, 7.6370440e+04, 1.9873214e+02],
6380 [41, 9.1393531e+04, 2.4483824e+02],
6381 [42, 1.1017111e+05, 2.8020699e+02],
6382 [43, 9.4552366e+04, 3.4394150e+02],
6383 [44, 1.2858281e+05, 6.8449252e+02],
6384 [45, 7.4583525e+04, 1.9544210e+02],
6385 [46, 9.2087490e+04, 2.0491066e+02],
6386 [47, 9.7507255e+04, 2.5162839e+02],
6387 [48, 1.0033842e+05, 2.7566430e+02],
6388 [49, 1.3048305e+05, 2.6797466e+02],
6389 [50, 1.0546796e+05, 1.9304384e+02],
6390 [51, 9.3099697e+04, 2.0773311e+02],
6391 [52, 4.6863758e+04, 1.3169068e+02],
6392 [53, 6.1055806e+04, 1.5448477e+02],
6393 [55, 6.8629994e+04, 1.6868673e+02],
6394 [56, 1.1005552e+05, 2.1940465e+02],
6395 [57, 1.0572760e+05, 1.9768486e+02],
6396 [58, 1.1176950e+05, 3.0009610e+02],
6397 [59, 9.8758603e+04, 3.3803895e+02],
6398 [60, 9.9517201e+04, 3.5137994e+02],
6399 [61, 5.4357946e+04, 2.5896579e+02],
6400 [62, 1.0899978e+05, 2.8720371e+02],
6401 [63, 8.4549759e+04, 4.1401837e+02],
6402 [64, 5.5014550e+04, 2.1135781e+02],
6403 [65, 8.0569666e+04, 2.3249709e+02],
6404 [66, 1.2936610e+05, 3.5218725e+02],
6405 [67, 3.6438010e+04, 8.7924003e+01],
6406 [70, 3.8763157e+04, 1.3325040e+02],
6407 [71, 8.5711411e+04, 2.9316183e+02],
6408 [72, 3.3211541e+04, 1.2182123e+02],
6409 [73, 3.2070576e+04, 1.2305430e+02]
6410 ]
6411 for res_num, value, error in data:
6412
6413 spin = return_spin(spin_id=":%s"%res_num)
6414
6415
6416 self.assertEqual(spin.r2eff['sq_cpmg_800.00000000_0.000_66.667'], value)
6417 self.assertEqual(spin.r2eff_err['sq_cpmg_800.00000000_0.000_66.667'], error)
6418
6419
6421 """Test the operation of the relax_disp.r2eff_read_spin user function."""
6422
6423
6424 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
6425
6426
6427 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
6428 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
6429 self.interpreter.spin.isotope('1H', spin_id='@H')
6430 self.interpreter.spin.isotope('15N', spin_id='@N')
6431
6432
6433 H_disp_points = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0]
6434 N_disp_points = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
6435 ids = []
6436 for value in H_disp_points:
6437 ids.append('1H_CPMG_%s' % value)
6438 for value in N_disp_points:
6439 ids.append('15N_CPMG_%s' % value)
6440 print("\n\nThe experiment IDs are %s." % ids)
6441
6442
6443 for id in ids:
6444 self.interpreter.spectrometer.frequency(id=id, frq=500e6)
6445 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
6446 for value in H_disp_points:
6447 self.interpreter.relax_disp.cpmg_setup(spectrum_id='1H_CPMG_%s' % value, cpmg_frq=value)
6448 for value in N_disp_points:
6449 self.interpreter.relax_disp.cpmg_setup(spectrum_id='15N_CPMG_%s' % value, cpmg_frq=value)
6450
6451
6452 for id, file, spin_id in [['1H_CPMG', 'hs_500.res', ':9@H'], ['15N_CPMG', 'ns_500.res', ':9@N']]:
6453
6454 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3)
6455
6456
6457 data = [
6458 ['cpmg_frqs', {'1H_CPMG_667.0': 667.0, '1H_CPMG_1067.0': 1067.0, '15N_CPMG_350.0': 350.0, '1H_CPMG_933.0': 933.0, '15N_CPMG_50.0': 50.0, '15N_CPMG_100.0': 100.0, '1H_CPMG_400.0': 400.0, '1H_CPMG_533.0': 533.0, '1H_CPMG_800.0': 800.0, '15N_CPMG_900.0': 900.0, '15N_CPMG_150.0': 150.0, '15N_CPMG_800.0': 800.0, '1H_CPMG_267.0': 267.0, '1H_CPMG_2667.0': 2667.0, '15N_CPMG_300.0': 300.0, '1H_CPMG_133.0': 133.0, '15N_CPMG_700.0': 700.0, '1H_CPMG_67.0': 67.0, '15N_CPMG_400.0': 400.0, '15N_CPMG_250.0': 250.0, '1H_CPMG_2133.0': 2133.0, '1H_CPMG_1600.0': 1600.0, '15N_CPMG_200.0': 200.0, '15N_CPMG_1000.0': 1000.0, '15N_CPMG_500.0': 500.0, '15N_CPMG_600.0': 600.0}],
6459 ['cpmg_frqs_list', [50.0, 67.0, 100.0, 133.0, 150.0, 200.0, 250.0, 267.0, 300.0, 350.0, 400.0, 500.0, 533.0, 600.0, 667.0, 700.0, 800.0, 900.0, 933.0, 1000.0, 1067.0, 1600.0, 2133.0, 2667.0]],
6460 ['dispersion_points', 24],
6461 ['exp_type', {'1H_CPMG_667.0': 'SQ CPMG', '1H_CPMG_1067.0': 'SQ CPMG', '15N_CPMG_350.0': 'SQ CPMG', '1H_CPMG_933.0': 'SQ CPMG', '15N_CPMG_50.0': 'SQ CPMG', '15N_CPMG_100.0': 'SQ CPMG', '1H_CPMG_400.0': 'SQ CPMG', '1H_CPMG_533.0': 'SQ CPMG', '1H_CPMG_800.0': 'SQ CPMG', '15N_CPMG_900.0': 'SQ CPMG', '15N_CPMG_150.0': 'SQ CPMG', '15N_CPMG_800.0': 'SQ CPMG', '1H_CPMG_267.0': 'SQ CPMG', '1H_CPMG_2667.0': 'SQ CPMG', '15N_CPMG_300.0': 'SQ CPMG', '1H_CPMG_133.0': 'SQ CPMG', '15N_CPMG_700.0': 'SQ CPMG', '1H_CPMG_67.0': 'SQ CPMG', '15N_CPMG_400.0': 'SQ CPMG', '15N_CPMG_250.0': 'SQ CPMG', '1H_CPMG_2133.0': 'SQ CPMG', '1H_CPMG_1600.0': 'SQ CPMG', '15N_CPMG_200.0': 'SQ CPMG', '15N_CPMG_1000.0': 'SQ CPMG', '15N_CPMG_500.0': 'SQ CPMG', '15N_CPMG_600.0': 'SQ CPMG'}],
6462 ['exp_type_list', ['SQ CPMG']],
6463 ['spectrometer_frq', {'1H_CPMG_667.0': 500000000.0, '1H_CPMG_1067.0': 500000000.0, '15N_CPMG_350.0': 500000000.0, '1H_CPMG_933.0': 500000000.0, '15N_CPMG_50.0': 500000000.0, '15N_CPMG_100.0': 500000000.0, '1H_CPMG_400.0': 500000000.0, '1H_CPMG_533.0': 500000000.0, '1H_CPMG_800.0': 500000000.0, '15N_CPMG_900.0': 500000000.0, '15N_CPMG_150.0': 500000000.0, '15N_CPMG_800.0': 500000000.0, '1H_CPMG_267.0': 500000000.0, '1H_CPMG_2667.0': 500000000.0, '15N_CPMG_300.0': 500000000.0, '1H_CPMG_133.0': 500000000.0, '15N_CPMG_700.0': 500000000.0, '1H_CPMG_67.0': 500000000.0, '15N_CPMG_400.0': 500000000.0, '15N_CPMG_250.0': 500000000.0, '1H_CPMG_2133.0': 500000000.0, '1H_CPMG_1600.0': 500000000.0, '15N_CPMG_200.0': 500000000.0, '15N_CPMG_1000.0': 500000000.0, '15N_CPMG_500.0': 500000000.0, '15N_CPMG_600.0': 500000000.0}],
6464 ['spectrometer_frq_count', 1],
6465 ['spectrometer_frq_list', [500000000.0]],
6466 ['spectrum_ids', ['1H_CPMG_67.0', '1H_CPMG_133.0', '1H_CPMG_267.0', '1H_CPMG_400.0', '1H_CPMG_533.0', '1H_CPMG_667.0', '1H_CPMG_800.0', '1H_CPMG_933.0', '1H_CPMG_1067.0', '1H_CPMG_1600.0', '1H_CPMG_2133.0', '1H_CPMG_2667.0', '15N_CPMG_50.0', '15N_CPMG_100.0', '15N_CPMG_150.0', '15N_CPMG_200.0', '15N_CPMG_250.0', '15N_CPMG_300.0', '15N_CPMG_350.0', '15N_CPMG_400.0', '15N_CPMG_500.0', '15N_CPMG_600.0', '15N_CPMG_700.0', '15N_CPMG_800.0', '15N_CPMG_900.0', '15N_CPMG_1000.0']]
6467 ]
6468 for name, value in data:
6469
6470 self.assert_(hasattr(cdp, name))
6471
6472
6473 obj = getattr(cdp, name)
6474 if not isinstance(data, dict):
6475 self.assertEqual(obj, value)
6476
6477
6478 else:
6479 for id in ids:
6480 self.assertEqual(obj[id], value[id])
6481
6482
6483 h_data = [
6484 [ 67.0, 21.47924, 0.42958],
6485 [ 133.0, 16.73898, 0.33478],
6486 [ 267.0, 9.97357, 0.19947],
6487 [ 400.0, 8.23877, 0.24737],
6488 [ 533.0, 7.59290, 0.24263],
6489 [ 667.0, 7.45843, 0.24165],
6490 [ 800.0, 7.11222, 0.23915],
6491 [ 933.0, 7.40880, 0.24129],
6492 [1067.0, 6.55191, 0.16629],
6493 [1600.0, 6.72177, 0.23637],
6494 [2133.0, 7.09629, 0.23904],
6495 [2667.0, 7.14675, 0.23940]
6496 ]
6497 for disp_point, value, error in h_data:
6498 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
6499 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
6500 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
6501 n_data = [
6502 [ 50.0, 27.15767, 0.54315],
6503 [ 100.0, 26.55781, 0.53116],
6504 [ 150.0, 24.73462, 0.49469],
6505 [ 200.0, 20.98617, 0.41972],
6506 [ 250.0, 17.82442, 0.35649],
6507 [ 300.0, 15.55352, 0.31107],
6508 [ 350.0, 13.78958, 0.27579],
6509 [ 400.0, 12.48334, 0.24967],
6510 [ 500.0, 11.55724, 0.23114],
6511 [ 600.0, 10.53874, 0.21077],
6512 [ 700.0, 10.07395, 0.20148],
6513 [ 800.0, 9.62952, 0.19259],
6514 [ 900.0, 9.49994, 0.19000],
6515 [1000.0, 8.71350, 0.17427]
6516 ]
6517 for disp_point, value, error in n_data:
6518 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
6519 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff[id], value)
6520 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff_err[id], error)
6521
6522
6524 """Test the relaxation dispersion 'R2eff' model for fixed time data in the auto-analysis."""
6525
6526
6527 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r2eff_calc.py')
6528
6529
6531 """Test the reading of a file containing r2eff values."""
6532
6533
6534 self.interpreter.residue.create(1, 'Gly')
6535 self.interpreter.residue.create(2, 'Gly')
6536 self.interpreter.residue.create(3, 'Gly')
6537
6538
6539 self.interpreter.relax_data.read(ri_id='R2eff.600', ri_type='R2eff', frq=600*1e6, file='r2eff.out', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r2eff', res_num_col=1, res_name_col=2, data_col=3, error_col=4)
6540
6541
6542 self.assertEqual(cdp.mol[0].res[0].spin[0].ri_data['R2eff.600'], 15.000)
6543 self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data['R2eff.600'], 4.2003)
6544 self.assertEqual(cdp.mol[0].res[2].spin[0].ri_data['R2eff.600'], 7.2385)
6545
6546
6548 """Test speeding up grid search. Support requst sr #3151 U{https://gna.org/support/index.php?3151}.
6549
6550 User function to set the R20 parameters in the default grid search using the minimum R2eff value.
6551
6552 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
6553 'SOD1-WT' CPMG data to the CR72 dispersion model.
6554
6555 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
6556 Data is for experiment at 25 degree Celcius.
6557 """
6558
6559
6560 pipe_name = 'base pipe'
6561 pipe_type = 'relax_disp'
6562 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
6563 select_spin_index = list(range(0, 1))
6564 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
6565
6566
6567 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
6568 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
6569
6570
6571 MODEL = "CR72"
6572
6573
6574 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
6575 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
6576 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
6577
6578
6579 self.interpreter.relax_disp.select_model(model=MODEL)
6580
6581
6582 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
6583
6584
6585 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6586
6587 spin_params = spin.params
6588
6589
6590 if spin_id == ":10@N":
6591 self.assertEqual(spin.r2[r20_key_600], 20.282732526087106)
6592 self.assertEqual(spin.r2[r20_key_500], 18.475299724356649)
6593
6594
6595 print("r2_600=%2.2f r2_500=%2.2f spin_id=%s resi=%i resn=%s"%(spin.r2[r20_key_600], spin.r2[r20_key_500], spin_id, resi, resn))
6596
6597
6598 self.assert_(spin.r2[r20_key_600] != spin.r2[r20_key_500])
6599
6600
6601 self.assert_(spin.r2[r20_key_600] > 0.0)
6602 self.assert_(spin.r2[r20_key_500] > 0.0)
6603
6604
6605 r2eff_600 = []
6606 r2eff_500 = []
6607 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
6608
6609 data_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
6610
6611
6612 r2eff = spin.r2eff[data_key]
6613 if frq == 599.8908617*1E6:
6614 r2eff_600.append(r2eff)
6615 elif frq == 499.862139*1E6:
6616 r2eff_500.append(r2eff)
6617
6618
6619 r2eff_600.sort()
6620 r2eff_500.sort()
6621
6622
6623 print("For r20 600MHz min r2eff=%3.3f."%(min(r2eff_600)))
6624 print(r2eff_600)
6625 self.assertEqual(spin.r2[r20_key_600], min(r2eff_600))
6626 print("")
6627
6628 print("For r20 500MHz min r2eff=%3.3f."%(min(r2eff_500)))
6629 print(r2eff_500)
6630 self.assertEqual(spin.r2[r20_key_500], min(r2eff_500))
6631 print("")
6632
6633 print("###########################################")
6634 print("Trying GRID SEARCH for minimum R2eff values")
6635
6636
6637 GRID_INC = 5
6638
6639 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
6640
6641
6642
6643 pipe_name_MODEL = "%s_%s_2"%(pipe_name, MODEL)
6644 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
6645 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
6646
6647
6648 self.interpreter.relax_disp.select_model(model=MODEL)
6649
6650
6651 for param in spin_params:
6652 print("Setting standard parameter for param: %s"%param)
6653 self.interpreter.value.set(param=param, index=None)
6654
6655
6656 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6657
6658 print("r2_600=%2.2f r2_500=%2.2f pA=%2.2f, dw=%2.2f, kex=%2.2f, spin_id=%s resi=%i resn=%s"%(spin.r2[r20_key_600], spin.r2[r20_key_500], spin.pA, spin.dw, spin.kex, spin_id, resi, resn))
6659
6660
6661 self.assertEqual(spin.r2[r20_key_600], 10.00)
6662 self.assertEqual(spin.r2[r20_key_500], 10.00)
6663 self.assertEqual(spin.pA, 0.9)
6664 self.assertEqual(spin.dw, 1.0)
6665 self.assertEqual(spin.kex, 1000.0)
6666
6667 print("###########################################")
6668 print("Trying GRID SEARCH for standard R2eff values")
6669
6670
6671 GRID_INC = 5
6672
6673 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
6674
6675
6676
6677 GRID_INC = 5
6678
6679
6680 MC_NUM = 3
6681
6682
6683 MODSEL = 'AIC'
6684
6685
6686
6687 OPT_FUNC_TOL = 1e-1
6688 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
6689 OPT_MAX_ITERATIONS = 1000
6690 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
6691
6692
6693 relax_disp.Relax_disp(pipe_name=pipe_name_r2eff, results_dir=ds.tmpdir, models=[MODEL], grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, set_grid_r20=True)
6694
6695
6697 """Error analysis of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
6698
6699 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
6700 'SOD1-WT' CPMG data to the CR72 dispersion model.
6701
6702 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
6703 Data is for experiment at 25 degree Celcius.
6704
6705 bug #21954 U{https://gna.org/bugs/index.php?21954}: Order of spectrum.error_analysis is important.
6706 """
6707
6708
6709 pipe_name = 'base pipe'
6710 pipe_type = 'relax_disp'
6711 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
6712 select_spin_index = list(range(0, 1))
6713 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
6714
6715
6716 repl_A = ['Z_A1', 'Z_A15']
6717 repl_B = ['Z_B1', 'Z_B18']
6718
6719
6720 spectrum_ids_A = []
6721 spectrum_ids_B = []
6722 for spectrum_id in cdp.spectrum_ids:
6723 if "A" in spectrum_id:
6724 spectrum_ids_A.append(spectrum_id)
6725 elif "B" in spectrum_id:
6726 spectrum_ids_B.append(spectrum_id)
6727
6728
6729 delattr(cdp, "var_I")
6730 delattr(cdp, "sigma_I")
6731
6732
6733 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
6734 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
6735
6736
6737 Errors_A_B = []
6738 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6739 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
6740 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
6741 Errors_A_B.append([A_err, B_err])
6742
6743
6744 delattr(cdp, "var_I")
6745 delattr(cdp, "sigma_I")
6746
6747
6748 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
6749 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
6750
6751
6752 Errors_B_A = []
6753 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6754 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
6755 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
6756 Errors_B_A.append([A_err, B_err])
6757
6758
6759 for i in range(len(Errors_A_B)):
6760 Error_A_B = Errors_A_B[i]
6761 Error_B_A = Errors_B_A[i]
6762 self.assertAlmostEqual(Error_A_B[0], Error_B_A[0], 4)
6763 self.assertAlmostEqual(Error_A_B[1], Error_B_A[1], 4)
6764
6765
6766 std_A = math.sqrt((cdp.var_I[repl_A[0]] + cdp.var_I[repl_A[1]])/2)
6767 std_A_fix = 2785.7263335738567
6768
6769 for id_A in spectrum_ids_A:
6770 self.assertEqual(cdp.sigma_I[id_A], std_A)
6771 self.assertAlmostEqual(cdp.sigma_I[id_A], std_A_fix, 7)
6772
6773 std_B = math.sqrt((cdp.var_I[repl_B[0]] + cdp.var_I[repl_B[1]])/2)
6774 std_B_fix = 4967.3772030667988
6775
6776 for id_B in spectrum_ids_B:
6777 self.assertEqual(cdp.sigma_I[id_B], std_B)
6778 self.assertAlmostEqual(cdp.sigma_I[id_B], std_B_fix, 7)
6779
6780
6782 """Optimisation of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
6783
6784 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
6785 'SOD1-WT' CPMG data to the CR72 dispersion model.
6786
6787 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
6788 Data is for experiment at 25 degree Celcius.
6789 """
6790
6791
6792 pipe_name = 'base pipe'
6793 pipe_type = 'relax_disp'
6794 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
6795 select_spin_index = list(range(0, 2))
6796 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
6797
6798
6799 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
6800 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
6801
6802
6803 MODEL = "CR72"
6804
6805
6806 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
6807 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
6808 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
6809
6810
6811 self.interpreter.relax_disp.select_model(model=MODEL)
6812
6813
6814 GRID_INC = 7
6815
6816
6817 grid_results = []
6818 mini_results = []
6819 clust_results = []
6820
6821
6822 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
6823
6824
6825 self.interpreter.relax_disp.insignificance(level=1.0)
6826
6827
6828 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
6829
6830
6831 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6832
6833 grid_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
6834
6835
6836
6837 set_func_tol = 1e-9
6838 set_max_iter = 100000
6839 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
6840
6841
6842 pA_values = []
6843 kex_values = []
6844 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6845
6846 mini_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
6847
6848
6849 pA_values.append(spin.pA)
6850
6851
6852 kex_values.append(spin.kex)
6853
6854 print("\n# Now print before and after minimisation.\n")
6855
6856
6857 for i in range(len(grid_results)):
6858
6859 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
6860 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
6861
6862 print("GRID r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
6863 print("MIN r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
6864
6865
6866
6867 pipe_name_MODEL_CLUSTER = "%s_%s_Cluster"%(pipe_name, MODEL)
6868 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL_CLUSTER)
6869 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL_CLUSTER)
6870
6871
6872 self.interpreter.relax_disp.select_model(model=MODEL)
6873
6874
6875 cluster_id = 'clust'
6876
6877
6878 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6879 self.interpreter.relax_disp.cluster(cluster_id, spin_id)
6880
6881
6882 self.interpreter.relax_disp.parameter_copy(pipe_from=pipe_name_MODEL, pipe_to=pipe_name_MODEL_CLUSTER)
6883
6884
6885 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6886 print(pA_values)
6887
6888 self.assertEqual(median(pA_values), spin.pA)
6889
6890
6891 self.assertEqual(median(kex_values), spin.kex)
6892
6893
6894 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
6895
6896
6897 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6898
6899 clust_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
6900
6901
6902 clust_pA = spin.pA
6903 clust_kex = spin.kex
6904
6905 print("\n# Now testing.\n")
6906
6907
6908 test_res = {}
6909 test_res[':10@N'] = {}
6910 test_res[':10@N']['r2600'] = 18.429755324773360
6911 test_res[':10@N']['r2500'] = 16.981349161968630
6912 test_res[':10@N']['dw'] = 2.700755859433969
6913 test_res[':10@N']['pA'] = 0.971531659288657
6914 test_res[':10@N']['kex'] = 3831.766337047963134
6915 test_res[':11@N'] = {}
6916 test_res[':11@N']['r2600'] = 18.193409421115213
6917 test_res[':11@N']['r2500'] = 17.308838135567765
6918 test_res[':11@N']['dw'] = 2.706650302761793
6919 test_res[':11@N']['pA'] = 0.971531659288657
6920 test_res[':11@N']['kex'] = 3831.766337047963134
6921
6922
6923 for i in range(len(grid_results)):
6924
6925 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
6926 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
6927 c_r2_600, c_r2_500, c_dw, c_pA, c_kex, c_chi2, c_spin_id, c_resi, c_resn = clust_results[i]
6928
6929 print("%s GRID r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
6930 print("%s MIN r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
6931 print("%s Clust r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_spin_id, c_r2_600, c_r2_500, c_dw, c_pA, c_kex, c_chi2, c_spin_id, c_resi, c_resn))
6932
6933
6934 self.assertEqual(clust_pA, c_pA)
6935 self.assertEqual(clust_kex, c_kex)
6936
6937
6938 if c_spin_id in test_res:
6939 self.assertAlmostEqual(c_r2_600, test_res[c_spin_id]['r2600'], 4)
6940 self.assertAlmostEqual(c_r2_500, test_res[c_spin_id]['r2500'], 4)
6941 self.assertAlmostEqual(c_dw, test_res[c_spin_id]['dw'], 3)
6942 self.assertAlmostEqual(c_pA, test_res[c_spin_id]['pA'], 5)
6943 self.assertAlmostEqual(c_kex, test_res[c_spin_id]['kex'], 1)
6944
6945
6946
6947
6948
7115
7116
7118 """Test the 'MMQ CR72' model fitting against Remco Sprangers' ClpP data.
7119
7120 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MMQ CPMG data with a fixed relaxation time period.
7121 """
7122
7123
7124 self.interpreter.reset()
7125
7126
7127 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
7128 self.interpreter.state.load(data_path+sep+'r2eff_values')
7129
7130
7131 model = 'MMQ CR72'
7132 pipe_name = "%s - relax_disp" % model
7133 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
7134 self.interpreter.pipe.switch(pipe_name=pipe_name)
7135
7136
7137 self.interpreter.relax_disp.select_model(model=model)
7138
7139
7140 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
7141
7142
7143 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
7144
7145
7146 spin135S = cdp.mol[0].res[0].spin[0]
7147 spin135F = cdp.mol[0].res[0].spin[1]
7148 spin137S = cdp.mol[0].res[1].spin[0]
7149 spin137F = cdp.mol[0].res[1].spin[1]
7150
7151
7152 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
7153 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
7154
7155
7156 spin135S.pA = 0.836591763632
7157 spin135S.kex = 241.806525261
7158
7159
7160 spin135S.r2 = {r20_key1: 28.2493431552, r20_key2: 31.7517334715}
7161 spin135S.dw = 0.583003118785
7162 spin135S.dwH = 0.0361441944301
7163
7164 spin135F.r2 = {r20_key1: 42.7201839991, r20_key2: 57.3178617389}
7165 spin135F.dw = 0.805849745104
7166 spin135F.dwH = 0.0215791945715
7167
7168 spin137S.r2 = {r20_key1: 26.0134115256, r20_key2: 30.575806934}
7169 spin137S.dw = 0.688107568372
7170 spin137S.dwH = 0.0344463604043
7171
7172 spin137F.r2 = {r20_key1: 46.6969397337, r20_key2: 58.602384101}
7173 spin137F.dw = 0.94978299907
7174 spin137F.dwH = 1.4818877939e-07
7175
7176
7177 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-10, max_iter=1000)
7178
7179
7180 print("\n\nOptimised parameters:\n")
7181 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
7182 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1]))
7183 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2]))
7184 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
7185 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
7186 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
7187 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
7188 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
7189 print("\n # Set the cluster specific parameters (only for the first spin).")
7190 print(" spin135S.pA = %s" % spin135S.pA)
7191 print(" spin135S.kex = %s" % spin135S.kex)
7192 print("\n # Set the initial parameter values.")
7193 print(" spin135S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135S.r2[r20_key1], spin135S.r2[r20_key2]))
7194 print(" spin135S.dw = %s" % spin135S.dw)
7195 print(" spin135S.dwH = %s" % spin135S.dwH)
7196 print("\n spin135F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135F.r2[r20_key1], spin135F.r2[r20_key2]))
7197 print(" spin135F.dw = %s" % spin135F.dw)
7198 print(" spin135F.dwH = %s" % spin135F.dwH)
7199 print("\n spin137S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137S.r2[r20_key1], spin137S.r2[r20_key2]))
7200 print(" spin137S.dw = %s" % spin137S.dw)
7201 print(" spin137S.dwH = %s" % spin137S.dwH)
7202 print("\n spin137F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137F.r2[r20_key1], spin137F.r2[r20_key2]))
7203 print(" spin137F.dw = %s" % spin137F.dw)
7204 print(" spin137F.dwH = %s" % spin137F.dwH)
7205
7206
7207 self.assertAlmostEqual(spin135S.r2[r20_key1], 28.2493445347425, 4)
7208 self.assertAlmostEqual(spin135S.r2[r20_key2], 31.7517352342937, 4)
7209 self.assertAlmostEqual(spin135S.pA, 0.836591714049569, 4)
7210 self.assertAlmostEqual(spin135S.dw, 0.583003004605869, 4)
7211 self.assertAlmostEqual(spin135S.dwH, 0.0361441894065963, 4)
7212 self.assertAlmostEqual(spin135S.kex/100, 241.806464344233/100, 4)
7213 self.assertAlmostEqual(spin135S.chi2, 12.4224060116473, 4)
7214
7215
7216 self.assertAlmostEqual(spin135F.r2[r20_key1], 42.7201844426839, 4)
7217 self.assertAlmostEqual(spin135F.r2[r20_key2], 57.3178718548898, 4)
7218 self.assertAlmostEqual(spin135F.pA, 0.836591714049569, 4)
7219 self.assertAlmostEqual(spin135F.dw, 0.805849748711916, 4)
7220 self.assertAlmostEqual(spin135F.dwH, 0.0215791669142752, 4)
7221 self.assertAlmostEqual(spin135F.kex/100, 241.806464344233/100, 4)
7222 self.assertAlmostEqual(spin135F.chi2, 12.4224060116473, 4)
7223
7224
7225 self.assertAlmostEqual(spin137S.r2[r20_key1], 26.013412509919, 4)
7226 self.assertAlmostEqual(spin137S.r2[r20_key2], 30.5758092335097, 4)
7227 self.assertAlmostEqual(spin137S.pA, 0.836591714049569, 4)
7228 self.assertAlmostEqual(spin137S.dw, 0.688107406812537, 4)
7229 self.assertAlmostEqual(spin137S.dwH, 0.034446357344577, 4)
7230 self.assertAlmostEqual(spin137S.kex/100, 241.806464344233/100, 4)
7231 self.assertAlmostEqual(spin137S.chi2, 12.4224060116473, 4)
7232
7233
7234 self.assertAlmostEqual(spin137F.r2[r20_key1], 46.696935090697, 4)
7235 self.assertAlmostEqual(spin137F.r2[r20_key2], 58.6023842513446, 4)
7236 self.assertAlmostEqual(spin137F.pA, 0.836591714049569, 4)
7237 self.assertAlmostEqual(spin137F.dw, 0.94978325541294, 4)
7238 self.assertAlmostEqual(spin137F.dwH, 1.5189362257653e-07, 4)
7239 self.assertAlmostEqual(spin137F.kex/100, 241.806464344233/100, 4)
7240 self.assertAlmostEqual(spin137F.chi2, 12.4224060116473, 4)
7241
7242
7244 """Test the 'NS MMQ 2-site' model fitting against Remco Sprangers' ClpP data.
7245
7246 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MQ CPMG data with a fixed relaxation time period.
7247 """
7248
7249
7250 self.interpreter.reset()
7251
7252
7253 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
7254 self.interpreter.state.load(data_path+sep+'r2eff_values')
7255
7256
7257 model = 'NS MMQ 2-site'
7258 pipe_name = "%s - relax_disp" % model
7259 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
7260 self.interpreter.pipe.switch(pipe_name=pipe_name)
7261
7262
7263 self.interpreter.relax_disp.select_model(model=model)
7264
7265
7266 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
7267
7268
7269 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
7270
7271
7272 spin135S = cdp.mol[0].res[0].spin[0]
7273 spin135F = cdp.mol[0].res[0].spin[1]
7274 spin137S = cdp.mol[0].res[1].spin[0]
7275 spin137F = cdp.mol[0].res[1].spin[1]
7276
7277
7278 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
7279 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
7280
7281
7282 spin135S.pA = 0.847378444499757
7283 spin135S.kex = 264.055604934724329
7284
7285
7286 spin135S.r2 = {r20_key1: 30.315119723745390, r20_key2: 37.411874745645299}
7287 spin135S.dw = 0.585574008745351
7288 spin135S.dwH = 0.000000000000002
7289
7290 spin135F.r2 = {r20_key1: 41.440843383778287, r20_key2: 56.989726795397893}
7291 spin135F.dw = 0.856699277665748
7292 spin135F.dwH = 0.000000000582587
7293
7294 spin137S.r2 = {r20_key1: 23.051695938570266, r20_key2: 28.352806483953824}
7295 spin137S.dw = 0.772904450844973
7296 spin137S.dwH = 0.183351478512970
7297
7298 spin137F.r2 = {r20_key1: 44.702032074210429, r20_key2: 56.453146052685319}
7299 spin137F.dw = 0.984568590342831
7300 spin137F.dwH = 0.000000001993458
7301
7302
7303 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-5, grad_tol=None, max_iter=100, constraints=True, scaling=True, verbosity=1)
7304
7305
7306 print("\n\nOptimised parameters:\n")
7307 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
7308 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1]))
7309 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2]))
7310 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
7311 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
7312 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
7313 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
7314 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
7315
7316
7317 return
7318
7319
7320 self.assertAlmostEqual(spin135S.r2[r20_key1], 30.3151197237454, 4)
7321 self.assertAlmostEqual(spin135S.r2[r20_key2], 37.4118747456453, 4)
7322 self.assertAlmostEqual(spin135S.pA, 0.847378444499757, 4)
7323 self.assertAlmostEqual(spin135S.dw, 0.585574008745351, 4)
7324 self.assertAlmostEqual(spin135S.dwH, 2e-15, 4)
7325 self.assertAlmostEqual(spin135S.kex, 264.055604934724, 4)
7326 self.assertAlmostEqual(spin135S.chi2, 13.859423588071, 1)
7327
7328
7329 self.assertAlmostEqual(spin135F.r2[r20_key1], 41.4408433837783, 4)
7330 self.assertAlmostEqual(spin135F.r2[r20_key2], 56.9897267953979, 4)
7331 self.assertAlmostEqual(spin135F.pA, 0.847378444499757, 4)
7332 self.assertAlmostEqual(spin135F.dw, 0.856699277665748, 4)
7333 self.assertAlmostEqual(spin135F.dwH, 5.82587e-10, 4)
7334 self.assertAlmostEqual(spin135F.kex, 264.055604934724, 4)
7335 self.assertAlmostEqual(spin135F.chi2, 13.859423588071, 1)
7336
7337
7338 self.assertAlmostEqual(spin137S.r2[r20_key1], 23.0516959385703, 4)
7339 self.assertAlmostEqual(spin137S.r2[r20_key2], 28.3528064839538, 4)
7340 self.assertAlmostEqual(spin137S.pA, 0.847378444499757, 4)
7341 self.assertAlmostEqual(spin137S.dw, 0.772904450844973, 4)
7342 self.assertAlmostEqual(spin137S.dwH, 0.18335147851297, 4)
7343 self.assertAlmostEqual(spin137S.kex, 264.055604934724, 4)
7344 self.assertAlmostEqual(spin137S.chi2, 13.859423588071, 1)
7345
7346
7347 self.assertAlmostEqual(spin137F.r2[r20_key1], 44.7020320742104, 4)
7348 self.assertAlmostEqual(spin137F.r2[r20_key2], 56.4531460526853, 4)
7349 self.assertAlmostEqual(spin137F.pA, 0.847378444499757, 4)
7350 self.assertAlmostEqual(spin137F.dw, 0.984568590342831, 4)
7351 self.assertAlmostEqual(spin137F.dwH, 2.0931309e-09, 4)
7352 self.assertAlmostEqual(spin137F.kex, 264.055604934724, 4)
7353 self.assertAlmostEqual(spin137F.chi2, 13.859423588071, 1)
7354
7355
7357 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data."""
7358
7359
7360 self.setup_tp02_data_to_ns_r1rho_2site()
7361
7362
7363 spin1 = cdp.mol[0].res[0].spin[0]
7364 spin2 = cdp.mol[0].res[1].spin[0]
7365
7366
7367 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
7368 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
7369
7370
7371 self.assertAlmostEqual(spin1.r2[r20_key1], 8.50207717367548, 4)
7372 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4680429589972, 4)
7373 self.assertAlmostEqual(spin1.pA, 0.864523128842393, 4)
7374 self.assertAlmostEqual(spin1.dw, 8.85204828994151, 4)
7375 self.assertAlmostEqual(spin1.kex/1000, 1199.56359549637/1000, 4)
7376 self.assertAlmostEqual(spin1.chi2, 2.99182130153514, 4)
7377
7378
7379 self.assertAlmostEqual(spin2.r2[r20_key1], 10.2099357790203, 4)
7380 self.assertAlmostEqual(spin2.r2[r20_key2], 16.2137648697873, 4)
7381 self.assertAlmostEqual(spin2.pA, 0.836488681031685, 4)
7382 self.assertAlmostEqual(spin2.dw, 9.5505714779503, 4)
7383 self.assertAlmostEqual(spin2.kex/1000, 1454.45726998929/1000, 4)
7384 self.assertAlmostEqual(spin2.chi2, 0.000402231563481261, 4)
7385
7386
7388 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data, when performing clustering."""
7389
7390
7391 self.setup_tp02_data_to_ns_r1rho_2site(clustering=True)
7392
7393
7394 spin1 = cdp.mol[0].res[0].spin[0]
7395 spin2 = cdp.mol[0].res[1].spin[0]
7396
7397
7398 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
7399 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
7400
7401
7402 self.assertAlmostEqual(spin1.r2[r20_key1], 8.48607207881462, 4)
7403 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4527609061722, 4)
7404 self.assertAlmostEqual(spin1.pA, 0.863093838784425, 4)
7405 self.assertAlmostEqual(spin1.dw, 8.86218096536618, 4)
7406 self.assertAlmostEqual(spin1.kex/1000, 1186.22749648299/1000, 4)
7407 self.assertAlmostEqual(spin1.chi2, 3.09500996065247, 4)
7408
7409
7410 self.assertAlmostEqual(spin2.r2[r20_key1], 10.4577906018883, 4)
7411 self.assertAlmostEqual(spin2.r2[r20_key2], 16.4455550953792, 4)
7412 self.assertAlmostEqual(spin2.pA, 0.863093838784425, 4)
7413 self.assertAlmostEqual(spin2.dw, 11.5841168862587, 4)
7414 self.assertAlmostEqual(spin2.kex/1000, 1186.22749648299/1000, 4)
7415 self.assertAlmostEqual(spin2.chi2, 3.09500996065247, 4)
7416
7417
7419 """Test the dispersion 'MP05' model fitting against the 'TP02' test data."""
7420
7421
7422 ds.fixed = True
7423 ds.models = ['R2eff', 'MP05']
7424
7425
7426 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
7427
7428
7429 self.interpreter.pipe.switch('MP05 - relax_disp')
7430
7431
7432 r1rho_prime = [[10.0058086343329, 15.005806870124], [12.0766320470785, 18.0767503536277]]
7433 pA = [0.775055484521586, 0.500000000036595]
7434 kex = [1235.20361276079, 2378.31403454691]
7435 delta_omega = [7.08194146569694, 5.4083562844306]
7436 chi2 = [0.0370400968727768, 0.182141732163934]
7437
7438
7439 spin1 = cdp.mol[0].res[0].spin[0]
7440 spin2 = cdp.mol[0].res[1].spin[0]
7441
7442
7443 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
7444 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
7445
7446
7447 print("\n\nOptimised parameters:\n")
7448 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
7449 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
7450 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
7451 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
7452 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
7453 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
7454 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
7455
7456
7457 spin_index = 0
7458 for spin, spin_id in spin_loop(return_id=True):
7459
7460 print("\nSpin %s." % spin_id)
7461
7462
7463 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
7464 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
7465 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
7466 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
7467 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
7468 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
7469
7470
7471 spin_index += 1
7472
7473
7475 """Test the dispersion 'TAP03' model fitting against the 'TP02' test data."""
7476
7477
7478 ds.fixed = True
7479 ds.models = ['R2eff', 'TAP03']
7480
7481
7482 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
7483
7484
7485 self.interpreter.pipe.switch('TAP03 - relax_disp')
7486
7487
7488 r1rho_prime = [[10.0058156589442, 15.005818505006], [12.0766046472748, 18.076648462452]]
7489 pA = [0.775042569092891, 0.500000000229685]
7490 kex = [1235.20852748765, 2379.47085580169]
7491 delta_omega = [7.08176806468445, 5.40708372863538]
7492 chi2 = [0.0371366837083293, 0.182212857256044]
7493
7494
7495 spin1 = cdp.mol[0].res[0].spin[0]
7496 spin2 = cdp.mol[0].res[1].spin[0]
7497
7498
7499 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
7500 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
7501
7502
7503 print("\n\nOptimised parameters:\n")
7504 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
7505 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
7506 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
7507 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
7508 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
7509 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
7510 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
7511
7512
7513 self.interpreter.pipe.switch('TAP03 - relax_disp')
7514 spin_index = 0
7515 for spin, spin_id in spin_loop(return_id=True):
7516
7517 print("\nSpin %s." % spin_id)
7518
7519
7520 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
7521 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
7522 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
7523 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
7524 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
7525 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
7526
7527
7528 spin_index += 1
7529
7530
7532 """Test the relaxation dispersion 'TP02' model curve fitting to fixed time synthetic data."""
7533
7534
7535 ds.fixed = True
7536
7537
7538 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
7539
7540
7541 r1rho_prime = [[10.0, 15.0], [12.0, 18.0]]
7542 pA = 0.7654321
7543 kex = 1234.56789
7544 delta_omega = [7.0, 9.0]
7545
7546
7547 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
7548 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
7549
7550
7551 self.interpreter.pipe.switch('TP02 - relax_disp')
7552 spin_index = 0
7553 for spin, spin_id in spin_loop(return_id=True):
7554
7555 print("\nSpin %s." % spin_id)
7556
7557
7558 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
7559 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
7560 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
7561 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3)
7562
7563
7564 spin_index += 1
7565
7566
7568 """System test of the value.write function to write intensities for an R1rho setup.
7569 This system test is to make sure, that modifying the API for special parameters theta and w_eff does not alter the functionality value.write.
7570
7571 This uses the data of the saved state attached to U{bug #21344<https://gna.org/bugs/?21344>}.
7572 """
7573
7574
7575 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
7576 self.interpreter.state.load(statefile, force=True)
7577
7578
7579 int_filepath = ds.tmpdir+sep+'int.out'
7580
7581
7582
7583 self.interpreter.value.write(param='peak_intensity', file='int.out', dir=ds.tmpdir, scaling=1.0, force=True)
7584
7585
7586 self.assert_(access(int_filepath, F_OK))
7587
7588
7589 int_file = open(int_filepath, 'r')
7590
7591
7592 for line in int_file:
7593
7594 if line[0] == "#":
7595 continue
7596
7597
7598 linesplit = line.split()
7599
7600
7601 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
7602 self.assertEqual(linesplit[5], "115571.4")
7603 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
7604 self.assertEqual(linesplit[5], "68377.52")
7605 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
7606 self.assertEqual(linesplit[5], "9141.689")
7607 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
7608 self.assertEqual(linesplit[5], "29123.77")
7609 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
7610 self.assertEqual(linesplit[5], "58914.94")
7611
7612
7613 int_file.close()
7614
7615
7617 """System test of the value.write function to write return values of theta from calc_rotating_frame_params() function for an R1rho setup.
7618
7619 This uses the data of the saved state attached to U{bug #21344<https://gna.org/bugs/?21344>}.
7620 """
7621
7622
7623 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
7624 self.interpreter.state.load(statefile, force=True)
7625
7626
7627 theta_filepath = ds.tmpdir+sep+'theta.out'
7628
7629
7630 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir, scaling=1.0, force=True)
7631
7632
7633 self.assert_(access(theta_filepath, F_OK))
7634
7635
7636 theta_file = open(theta_filepath, 'r')
7637
7638
7639 for line in theta_file:
7640
7641 if line[0] == "#":
7642 continue
7643
7644 print(line[:-1])
7645
7646
7647 linesplit = line.split()
7648
7649
7650 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
7651 self.assertNotEqual(linesplit[5], "None")
7652 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
7653 self.assertNotEqual(linesplit[5], "None")
7654 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
7655 self.assertNotEqual(linesplit[5], "None")
7656 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
7657 self.assertNotEqual(linesplit[5], "None")
7658 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
7659 self.assertNotEqual(linesplit[5], "None")
7660
7661
7662 theta_file.close()
7663
7664
7666 """System test of the value.write function to write return values of w_eff from calc_rotating_frame_params() function for an R1rho setup.
7667
7668 This uses the data of the saved state attached to U{bug #21344<https://gna.org/bugs/?21344>}.
7669 """
7670
7671
7672 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
7673 self.interpreter.state.load(statefile, force=True)
7674
7675
7676 w_eff_filepath = ds.tmpdir+sep+'w_eff.out'
7677
7678
7679 self.interpreter.value.write(param='w_eff', file='w_eff.out', dir=ds.tmpdir, scaling=1.0, force=True)
7680
7681
7682 self.assert_(access(w_eff_filepath, F_OK))
7683
7684
7685 w_eff_file = open(w_eff_filepath, 'r')
7686
7687
7688 for line in w_eff_file:
7689
7690 if line[0] == "#":
7691 continue
7692
7693 print(line[:-1])
7694
7695
7696 linesplit = line.split()
7697
7698
7699 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
7700 self.assertNotEqual(linesplit[5], "None")
7701 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
7702 self.assertNotEqual(linesplit[5], "None")
7703 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
7704 self.assertNotEqual(linesplit[5], "None")
7705 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
7706 self.assertNotEqual(linesplit[5], "None")
7707 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
7708 self.assertNotEqual(linesplit[5], "None")
7709
7710
7711 w_eff_file.close()
7712
7713
7715 """System test of the auto_analysis value.write function to write theta and w_eff values for an R1rho setup.
7716
7717 This uses the data of the saved state attached to U{bug #21344<https://gna.org/bugs/?21344>}.
7718 """
7719
7720
7721 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344.bz2'
7722 self.interpreter.state.load(statefile, force=True)
7723
7724
7725 pipe_name = 'base pipe'
7726 pipe_bundle = 'relax_disp'
7727 pipe_type = 'relax_disp'
7728
7729
7730 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
7731
7732
7733 self.interpreter.deselect.all()
7734
7735
7736 select_spin_ids = [
7737 ":13@N",
7738 ":15@N",
7739 ":16@N",
7740 ":25@N",
7741 ":26@N",
7742 ":28@N",
7743 ":39@N",
7744 ":40@N",
7745 ":41@N",
7746 ":43@N",
7747 ":44@N",
7748 ":45@N",
7749 ":49@N",
7750 ":52@N",
7751 ":53@N"]
7752
7753
7754 for curspin in select_spin_ids:
7755 print("Selecting spin %s"%curspin)
7756 self.interpreter.deselect.reverse(spin_id=curspin)
7757
7758
7759 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
7760
7761
7762 MODELS = ['R2eff']
7763
7764
7765 GRID_INC = 4
7766
7767
7768 MC_NUM = 3
7769
7770
7771 MODSEL = 'AIC'
7772
7773
7774
7775 OPT_FUNC_TOL = 1e-1
7776 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
7777 OPT_MAX_ITERATIONS = 1000
7778 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
7779
7780
7781 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=ds.tmpdir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
7782
7783
7784
7785 theta_filepath = ds.tmpdir+sep+MODELS[0]+sep+'theta.out'
7786 w_eff_filepath = ds.tmpdir+sep+MODELS[0]+sep+'w_eff.out'
7787
7788
7789 self.assert_(access(theta_filepath, F_OK))
7790 self.assert_(access(w_eff_filepath, F_OK))
7791
7792
7793 theta_file = open(theta_filepath, 'r')
7794 theta_result = [
7795 "# Parameter description: Rotating frame tilt angle : ( theta = arctan(w_1 / Omega) ) (rad).\n",
7796 "#\n",
7797 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n",
7798 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7799 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7800 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7801 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7802 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7803 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7804 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7805 "None 13 L None N 1.83827367612531 None 1.79015307643158 None 2.2768687598681 None 2.08461171779445 None 2.00120623474388 None 1.92825070277699 None 1.47212860033516 None 1.12978017906854 None 1.20415336139956 None 0.901691390796334 None 0.687390207543568 None 0.455635480573046 None 0.281637123971289 None 0.138259661766539 None \n",
7806 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7807 "None 15 R None N 1.58367544790673 None 1.58127411936947 None 1.61085209029811 None 1.59731540507347 None 1.59237108385522 None 1.58834866344307 None 1.2251048782537 None 0.938142786712004 None 1.03297495592991 None 0.683284686224254 None 0.594447788256641 None 0.383528609383686 None 0.262780814059893 None 0.133469839450564 None \n",
7808 "None 16 T None N 1.40984232256624 None 1.43947245672073 None 1.10299856647417 None 1.24811470332083 None 1.30521602599932 None 1.35302443831853 None 1.07923777467974 None 0.833345927788896 None 0.934350308974616 None 0.581325254389991 None 0.543659670184793 None 0.346238480454282 None 0.251454336191817 None 0.130436714663781 None \n",
7809 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7810 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7811 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7812 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7813 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7814 "None 25 Q None N 1.81569700258844 None 1.77137827615015 None 2.23175875585624 None 2.04612705363098 None 1.9673155780155 None 1.89908711012298 None 1.44829660124856 None 1.11023386429581 None 1.18716091371256 None 0.877306975624962 None 0.677790118853413 None 0.447932002242236 None 0.279785379050945 None 0.137802891887767 None \n",
7815 "None 26 Q None N 1.61128821168674 None 1.60374392042003 None 1.69619923953765 None 1.65403989292986 None 1.63856717205868 None 1.62595755714564 None 1.24977859227795 None 0.956353494917591 None 1.04972090035774 None 0.702164059520172 None 0.603227813742091 None 0.390116910781037 None 0.264658552037535 None 0.133960994297096 None \n",
7816 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7817 "None 28 Q None N 1.65182797011356 None 1.63676707684161 None 1.81830827892972 None 1.7365089711986 None 1.70601955220877 None 1.68102938663686 None 1.28685736157369 None 0.984047498595701 None 1.0749792109454 None 0.731585685663053 None 0.616577997665602 None 0.400219205533665 None 0.267471993812649 None 0.134690869499646 None \n",
7818 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7819 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7820 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7821 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7822 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7823 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7824 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7825 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7826 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7827 "None 39 L None N 1.76426439181176 None 1.72885318885161 None 2.11826300085737 None 1.95430201082222 None 1.88794717058464 None 1.83172922971397 None 1.39549951193417 None 1.06783946148624 None 1.14997013232702 None 0.826128785942585 None 0.657105386950171 None 0.431542911580536 None 0.275725736430539 None 0.136791385554619 None \n",
7828 "None 40 M None N 1.5521741199158 None 1.55564594516135 None 1.51290906497298 None 1.53245929150759 None 1.53960430408466 None 1.54541832596591 None 1.19750223001929 None 0.917959090226757 None 1.01428385962747 None 0.662779584695967 None 0.584708929219264 None 0.376271266885303 None 0.260671619214194 None 0.132914250767089 None \n",
7829 "None 41 A None N 1.68339451828261 None 1.66252964414082 None 1.90911961276946 None 1.79959323497326 None 1.75801925517113 None 1.72370710837265 None 1.31646868936419 None 1.00647189763597 None 1.09525348649914 None 0.75605702767542 None 0.627395557358039 None 0.408481831044309 None 0.269716174238842 None 0.135267948387412 None \n",
7830 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7831 "None 43 F None N 1.58506597154432 None 1.58240542750303 None 1.61517196062351 None 1.60017740004898 None 1.59469990835425 None 1.59024353162528 None 1.22633651794829 None 0.939047922181951 None 1.03380990731605 None 0.684214484755514 None 0.594884298549546 None 0.383855128702894 None 0.262874695048502 None 0.13349447283116 None \n",
7832 "None 44 I None N 1.57575471961837 None 1.57483015671791 None 1.58622388390755 None 1.58100758841935 None 1.57910319967536 None 1.57755415552211 None 1.21811077066835 None 0.933010299763027 None 1.02823520295828 None 0.67802911457195 None 0.591972285081647 None 0.381678892926696 None 0.262247347241724 None 0.133329708422379 None \n",
7833 "None 45 K None N 1.77147501495754 None 1.73479633022489 None 2.13509660780385 None 1.96751045408372 None 1.89924480319914 None 1.84124387452692 None 1.40277881643715 None 1.07361367582571 None 1.15506365550891 None 0.832963505534767 None 0.659913187081268 None 0.433751178249555 None 0.276282572106685 None 0.13693095791902 None \n",
7834 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7835 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7836 "None 49 A None N 2.00297059962685 None 1.92978318052058 None 2.53305709323468 None 2.33052197276846 None 2.22870514722639 None 2.13201782446864 None 1.6587904412969 None 1.29333162369472 None 1.34311052758116 None 1.12559033900783 None 0.770195063841652 None 0.524846264860003 None 0.296857751274362 None 0.141908833673671 None \n",
7837 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7838 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7839 "None 52 V None N 1.82421571143794 None 1.77845404105203 None 2.24910726268822 None 2.06078232916932 None 1.98017451806059 None 1.91012195713554 None 1.45724107606646 None 1.11753869321304 None 1.19352234944057 None 0.886361068343012 None 0.681372607920812 None 0.450799407357501 None 0.280478735779163 None 0.137974257665877 None \n",
7840 "None 53 A None N 2.05019708195234 None 1.97089957318506 None 2.58789168363698 None 2.39027806684801 None 2.28731354878582 None 2.1872118539319 None 1.7165709935896 None 1.34832362477229 None 1.38879751095815 None 1.2085314357749 None 0.799450059125864 None 0.550583841461621 None 0.30195492609136 None 0.143090604877102 None \n",
7841 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7842 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7843 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7844 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7845 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n"
7846 ]
7847
7848 lines = theta_file.readlines()
7849 for i in range(len(lines)):
7850
7851 if theta_result[i][0] == "#":
7852 self.assertEqual(theta_result[i], lines[i])
7853
7854 if theta_result[i] == lines[i]:
7855 self.assertEqual(theta_result[i], lines[i])
7856
7857 else:
7858
7859 print(theta_result[i])
7860 print(lines[i])
7861
7862
7863 self.assertEqual(theta_result[i][:62], lines[i][:62])
7864
7865
7866 theta_result_s = theta_result[i][62:].split()[::2]
7867 print(theta_result_s )
7868 lines_s = lines[i][62:].split()[::2]
7869 print(lines_s)
7870
7871 for j in range(len(lines_s)):
7872 print(theta_result_s[j], lines_s[j])
7873
7874 self.assertAlmostEqual(float(theta_result_s[j]), float(lines_s[j]), 14)
7875
7876
7877 theta_file.close()
7878
7879 w_eff_file = open(w_eff_filepath, 'r')
7880 w_eff_result = [
7881 "# Parameter description: Effective field in rotating frame : ( w_eff = sqrt(Omega^2 + w_1^2) ) (rad.s^-1).\n",
7882 "#\n",
7883 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n",
7884 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7885 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7886 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7887 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7888 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7889 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7890 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7891 "None 13 L None N 8737.12883908829 None 10612.1226552258 None 3558.93734069587 None 4698.27194621826 None 5534.46153956037 None 6599.82570817753 None 8467.62674839481 None 9318.00441649087 None 11095.2662520767 None 6412.33580591254 None 13279.9803044242 None 11430.254637056 None 30318.7268264644 None 61141.1080046448 None \n",
7892 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7893 "None 15 R None N 8427.14155005377 None 10358.3995676635 None 2710.22680763322 None 4093.04942975722 None 5030.86065069262 None 6183.60685459024 None 8956.28403254202 None 10448.6627754369 None 12060.4428066937 None 7966.64282975241 None 15045.8392092364 None 13441.3586252373 None 32438.4764809909 None 63321.5201471181 None \n",
7894 "None 16 T None N 8536.7818857229 None 10447.792678989 None 3034.01707453628 None 4314.2767521567 None 5212.43600885913 None 6332.21319855067 None 9558.14311447582 None 11384.2336494604 None 12879.4604966293 None 9159.34604475399 None 16290.1746838959 None 14821.0200530829 None 33866.5933527757 None 64785.3205696403 None \n",
7895 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7896 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7897 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7898 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7899 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7900 "None 25 Q None N 8685.60895531182 None 10569.7459677762 None 3430.51272680396 None 4601.75421490393 None 5452.76508815826 None 6531.46859076009 None 8490.06475886501 None 9406.58372902508 None 11169.7602637607 None 6540.38696356753 None 13437.7348017798 None 11613.1632549021 None 30514.0741594726 None 61342.4792156782 None \n",
7901 "None 26 Q None N 8433.35533683544 None 10363.4554631194 None 2729.48656005151 None 4105.82770792005 None 5041.26238350827 None 6192.07245313098 None 8880.08366342131 None 10312.6868786802 None 11942.8320576165 None 7787.44854491812 None 14853.4987024375 None 13225.7048162038 None 32213.6690023282 None 63090.7407990801 None \n",
7902 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7903 "None 28 Q None N 8454.18308422202 None 10380.4112885894 None 2793.17494362899 None 4148.43953208179 None 5076.02756135055 None 6220.40920270029 None 8777.91538040813 None 10118.8737706315 None 11775.8792998529 None 7528.90766101027 None 14572.4015102398 None 12909.211050939 None 31882.8171856889 None 62750.9120842199 None \n",
7904 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7905 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7906 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7907 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7908 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7909 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7910 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7911 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7912 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7913 "None 39 L None N 8586.6405431352 None 10488.5710521378 None 3171.59430904777 None 4412.11227722123 None 5293.69814015286 None 6399.27143075725 None 8557.58926327909 None 9617.45773774313 None 11347.9169998729 None 6840.20010813426 None 13795.1250622375 None 12024.9041436853 None 30951.651485352 None 61793.2130509111 None \n",
7914 "None 40 M None N 8427.90394711227 None 10359.0198301036 None 2712.59646573568 None 4094.61889210019 None 5032.13762965554 None 6184.6458240746 None 9049.68452800053 None 10607.7913029633 None 12198.5639821231 None 8174.23271685285 None 15266.4924700447 None 13687.9010998756 None 32694.9043143038 None 63584.6371927381 None \n",
7915 "None 41 A None N 8480.14299737436 None 10401.5648897003 None 2870.79081440785 None 4201.09083283266 None 5119.14733505123 None 6255.64579267482 None 8706.50768957471 None 9972.71017314947 None 11650.5225246067 None 7331.28858930568 None 14354.1616183112 None 12662.3378547029 None 31623.9195264738 None 62484.8290612112 None \n",
7916 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7917 "None 43 F None N 8427.30062786474 None 10358.5289868368 None 2710.7214015056 None 4093.37694357637 None 5031.12711571215 None 6183.82364721878 None 8952.31975962078 None 10441.7375680915 None 12054.4435931163 None 7957.55789315654 None 15036.1316712316 None 13430.4914212645 None 32427.1596037519 None 63309.9050677925 None \n",
7918 "None 44 I None N 8426.54623319716 None 10357.9152496503 None 2708.3751705368 None 4091.82359712664 None 5029.86337809029 None 6182.79552045043 None 8979.12144335458 None 10488.2688526334 None 12094.7720286018 None 8018.51779989075 None 15101.1843990883 None 13503.2816173444 None 32502.9389163062 None 63387.6763306952 None \n",
7919 "None 45 K None N 8599.01176345321 None 10498.7013581079 None 3204.93649737055 None 4436.14046641897 None 5313.74138343704 None 6415.86177652694 None 8546.79665373249 None 9587.16245449134 None 11322.2529042385 None 6797.53838612575 None 13745.1536613763 None 11967.5433300612 None 30890.8603419261 None 61730.6213936947 None \n",
7920 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7921 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7922 "None 49 A None N 9279.63849130869 None 11063.0654625247 None 4737.11992391463 None 5643.40583860235 None 6356.45614406507 None 7302.87406141381 None 8459.17105047661 None 8761.54554569995 None 10632.2343488142 None 5572.92782399155 None 12102.1714908775 None 10037.6988885228 None 28806.6916858172 None 59579.0348769179 None \n",
7923 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7924 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7925 "None 52 V None N 8704.45610117774 None 10585.2389163429 None 3477.9549539207 None 4637.22923167743 None 5482.73656118686 None 6556.5108895527 None 8481.06470969555 None 9372.86414918436 None 11141.3782476763 None 6491.79686536093 None 13378.2843939736 None 11544.3205736882 None 30440.62308788 None 61266.7742546508 None \n",
7926 "None 53 A None N 9497.02860450276 None 11246.0339326126 None 5149.96766581255 None 5994.15475647208 None 6669.81232845336 None 7577.19152075731 None 8516.77431951689 None 8639.36099840319 None 10531.7750336522 None 5378.79193153767 None 11752.8060152439 None 9613.59939949642 None 28334.9153747994 None 59090.2988815445 None \n",
7927 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7928 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7929 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7930 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
7931 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n"
7932 ]
7933
7934 lines = w_eff_file.readlines()
7935 for i in range(len(lines)):
7936
7937 if w_eff_result[i][0] == "#":
7938 self.assertEqual(w_eff_result[i], lines[i])
7939
7940 if w_eff_result[i] == lines[i]:
7941 self.assertEqual(w_eff_result[i], lines[i])
7942
7943 else:
7944
7945 print(w_eff_result[i])
7946 print(lines[i])
7947
7948
7949 self.assertEqual(w_eff_result[i][:62], lines[i][:62])
7950
7951
7952 w_eff_result_s = w_eff_result[i][62:].split()[::2]
7953 print(w_eff_result_s )
7954 lines_s = lines[i][62:].split()[::2]
7955 print(lines_s)
7956
7957 for j in range(len(lines_s)):
7958 print(w_eff_result_s[j], lines_s[j])
7959
7960 self.assertAlmostEqual(float(w_eff_result_s[j]), float(lines_s[j]), 14)
7961
7962
7963 w_eff_file.close()
7964
7965
7967 """Test the user function for estimating R2eff errors from exponential curve fitting, and compare it with Monte-Carlo simulations.
7968
7969 This follows Task 7822.
7970 U{task #7822<https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
7971
7972 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
7973 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
7974 """
7975
7976
7977 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep
7978
7979
7980 pipe_name = 'base pipe'
7981 pipe_bundle = 'relax_disp'
7982 pipe_type = 'relax_disp'
7983
7984
7985 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type)
7986
7987 file = data_path + '1_setup_r1rho_GUI.py'
7988 self.interpreter.script(file=file, dir=None)
7989
7990
7991 self.interpreter.deselect.spin(spin_id=':1-100', change_all=False)
7992
7993
7994 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
7995
7996
7997 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
7998
7999
8000 check_intensity_errors()
8001
8002
8003 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=11, constraints=True, verbosity=1)
8004
8005
8006 min_algor = 'Newton'
8007 constraints = True
8008 if constraints:
8009 min_options = ('%s'%(min_algor),)
8010
8011 min_algor = 'Method of Multipliers'
8012 scaling_matrix = assemble_scaling_matrix(scaling=True)
8013
8014
8015 all_spin_ids = []
8016 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8017 all_spin_ids.append(spin_id)
8018
8019 spins = spin_ids_to_containers(all_spin_ids[:1])
8020
8021
8022 A, b = linear_constraints(spins=spins, scaling_matrix=scaling_matrix[0])
8023 else:
8024 min_options = ()
8025 A, b = None, None
8026 min_options = ()
8027 sim_boot = 200
8028 scaling_list = [1.0, 1.0]
8029
8030
8031 self.interpreter.minimise.execute(min_algor=min_algor, constraints=constraints, verbosity=1)
8032
8033
8034 err_attr_list = ['r2eff_err', 'i0_err']
8035
8036 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8037
8038 for err_attr in err_attr_list:
8039 if hasattr(cur_spin, err_attr):
8040 delattr(cur_spin, err_attr)
8041
8042
8043 my_dic = {}
8044 param_key_list = []
8045 est_keys = []
8046 est_key = '-2'
8047 est_keys.append(est_key)
8048 spin_id_list = []
8049
8050 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8051
8052 my_dic[spin_id] = {}
8053
8054
8055 my_dic[spin_id][est_key] = {}
8056
8057
8058 spin_id_list.append(spin_id)
8059
8060
8061 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
8062
8063 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
8064
8065 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
8066
8067
8068 param_key_list.append(param_key)
8069
8070
8071 my_dic[spin_id][est_key][param_key] = {}
8072
8073 values = []
8074 errors = []
8075 times = []
8076 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
8077 values.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time))
8078 errors.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True))
8079 times.append(time)
8080
8081
8082 values = asarray(values)
8083 errors = asarray(errors)
8084 times = asarray(times)
8085
8086 r2eff = getattr(cur_spin, 'r2eff')[param_key]
8087 i0 = getattr(cur_spin, 'i0')[param_key]
8088
8089 R_m_sim_l = []
8090 I0_m_sim_l = []
8091 for j in range(sim_boot):
8092 if j in range(0, 100000, 100):
8093 print("Simulation %i"%j)
8094
8095
8096
8097 I_err = []
8098 for j, error in enumerate(errors):
8099 I_error = gauss(values[j], error)
8100 I_err.append(I_error)
8101
8102 I_err = asarray(I_err)
8103
8104 x0 = [r2eff, i0]
8105 setup(num_params=len(x0), num_times=len(times), values=I_err, sd=errors, relax_times=times, scaling_matrix=scaling_list)
8106
8107
8108
8109
8110
8111
8112
8113
8114 params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=func, dfunc=dfunc, d2func=d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, A=A, b=b, full_output=True, print_flag=0)
8115
8116 R_m_sim_j, I0_m_sim_j = params_minfx_sim_j
8117 R_m_sim_l.append(R_m_sim_j)
8118 I0_m_sim_l.append(I0_m_sim_j)
8119
8120
8121 sigma_R_sim = std(asarray(R_m_sim_l), ddof=1)
8122 sigma_I0_sim = std(asarray(I0_m_sim_l), ddof=1)
8123 my_dic[spin_id][est_key][param_key]['r2eff_err'] = sigma_R_sim
8124 my_dic[spin_id][est_key][param_key]['i0_err'] = sigma_I0_sim
8125
8126
8127 self.interpreter.relax_disp.r2eff_err_estimate()
8128
8129 est_key = '-1'
8130 est_keys.append(est_key)
8131
8132
8133 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8134
8135 my_dic[spin_id][est_key] = {}
8136
8137 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
8138
8139 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
8140
8141
8142 my_dic[spin_id][est_key][param_key] = {}
8143
8144
8145
8146 for err_attr in err_attr_list:
8147 if hasattr(cur_spin, err_attr):
8148 get_err_attr = getattr(cur_spin, err_attr)[param_key]
8149 else:
8150 get_err_attr = 0.0
8151
8152
8153 my_dic[spin_id][est_key][param_key][err_attr] = get_err_attr
8154
8155
8156
8157 mc_number_list = list(range(0, 1000, 250))
8158
8159 sim_attr_list = ['chi2_sim', 'f_count_sim', 'g_count_sim', 'h_count_sim', 'i0_sim', 'iter_sim', 'peak_intensity_sim', 'r2eff_sim', 'select_sim', 'warning_sim']
8160
8161
8162 for number in mc_number_list:
8163
8164 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8165
8166 for err_attr in err_attr_list:
8167 if hasattr(cur_spin, err_attr):
8168 delattr(cur_spin, err_attr)
8169
8170
8171 for sim_attr in sim_attr_list:
8172 if hasattr(cur_spin, sim_attr):
8173 delattr(cur_spin, sim_attr)
8174
8175 self.interpreter.monte_carlo.setup(number=number)
8176 self.interpreter.monte_carlo.create_data()
8177 self.interpreter.monte_carlo.initial_values()
8178 self.interpreter.minimise.execute(min_algor=min_algor, constraints=constraints)
8179 self.interpreter.eliminate()
8180 self.interpreter.monte_carlo.error_analysis()
8181
8182 est_key = '%i'%number
8183 est_keys.append(est_key)
8184
8185
8186 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8187
8188 my_dic[spin_id][est_key] = {}
8189
8190 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
8191
8192 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
8193
8194
8195 my_dic[spin_id][est_key][param_key] = {}
8196
8197
8198
8199 for err_attr in err_attr_list:
8200 if hasattr(cur_spin, err_attr):
8201 get_err_attr = getattr(cur_spin, err_attr)[param_key]
8202 else:
8203 get_err_attr = 0.0
8204
8205
8206 my_dic[spin_id][est_key][param_key][err_attr] = get_err_attr
8207
8208
8209 err_attr = err_attr_list[0]
8210
8211
8212 text_list = []
8213
8214
8215 for spin_id in spin_id_list:
8216 for est_key in est_keys:
8217
8218 r2eff_err_list = []
8219
8220 for param_key in param_key_list:
8221
8222 r2eff_err = my_dic[spin_id][est_key][param_key][err_attr]
8223
8224
8225 r2eff_err_list.append(r2eff_err)
8226
8227
8228 sum_array = sum(array(r2eff_err_list))
8229
8230
8231 r2eff_err_str = " ".join(format(x, "2.3f") for x in r2eff_err_list)
8232
8233
8234 text = "%8s %s sum= %2.3f" % (est_key, r2eff_err_str, sum_array)
8235 text_list.append(text)
8236
8237
8238
8239 filepath = NamedTemporaryFile(delete=False).name
8240
8241 w_file = open(filepath, 'w')
8242
8243 print("Printing the estimated R2eff error as function of estimation from Co-variance and number of Monte-Carlo simulations.")
8244
8245 for text in text_list:
8246
8247 print(text)
8248
8249
8250 w_file.write(text+"\n")
8251
8252
8253 w_file.close()
8254
8255 print("Filepath is: %s"%filepath)
8256 print("Start 'gnuplot' and write:")
8257 print("set term dumb")
8258 print("plot '%s' using 1:17 title 'R2eff error as function of MC number' w linespoints "%filepath)
8259
8260
8262 """Verification of test_r1rho_kjaergaard_missing_r1."""
8263
8264
8265
8266
8267
8268 print("\n\n################")
8269 print("Printing results")
8270 print("################\n")
8271 for model in models:
8272
8273 if model == MODEL_R2EFF:
8274 continue
8275
8276
8277 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
8278 print("\nModel: %s" % (model))
8279
8280
8281 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8282
8283 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
8284
8285
8286 print("Optimised parameters for spin: %s" % (spin_string))
8287 for param in cur_spin.params + ['chi2']:
8288
8289 if param in ['r1', 'r2']:
8290 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
8291
8292 r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
8293
8294
8295 value = getattr(cur_spin, param)[r20_key]
8296
8297
8298 print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value))
8299
8300
8301 if spin_id == ':52@N':
8302 if param == 'r1':
8303 if model == MODEL_NOREX:
8304 if r2eff_estimate == 'direct':
8305 self.assertAlmostEqual(value, 1.46138805)
8306 elif r2eff_estimate == 'MC2000':
8307 self.assertAlmostEqual(value, 1.46328102)
8308 elif r2eff_estimate == 'chi2_pyt':
8309 self.assertAlmostEqual(value, 1.43820629)
8310 elif model == MODEL_DPL94:
8311 if r2eff_estimate == 'direct':
8312 self.assertAlmostEqual(value, 1.44845742)
8313 elif r2eff_estimate == 'MC2000':
8314 self.assertAlmostEqual(value, 1.45019848)
8315 elif r2eff_estimate == 'chi2_pyt':
8316 self.assertAlmostEqual(value, 1.44666512)
8317 elif model == MODEL_TP02:
8318 if r2eff_estimate == 'direct':
8319 self.assertAlmostEqual(value, 1.54354392)
8320 elif r2eff_estimate == 'MC2000':
8321 self.assertAlmostEqual(value, 1.54352369)
8322 elif r2eff_estimate == 'chi2_pyt':
8323 self.assertAlmostEqual(value, 1.55964020)
8324 elif model == MODEL_TAP03:
8325 if r2eff_estimate == 'direct':
8326 self.assertAlmostEqual(value, 1.54356410)
8327 elif r2eff_estimate == 'MC2000':
8328 self.assertAlmostEqual(value, 1.54354367)
8329 elif r2eff_estimate == 'chi2_pyt':
8330 self.assertAlmostEqual(value, 1.55967157)
8331 elif model == MODEL_MP05:
8332 if r2eff_estimate == 'direct':
8333 self.assertAlmostEqual(value, 1.54356416)
8334 elif r2eff_estimate == 'MC2000':
8335 self.assertAlmostEqual(value, 1.54354372)
8336 elif r2eff_estimate == 'chi2_pyt':
8337 self.assertAlmostEqual(value, 1.55967163)
8338 elif model == MODEL_NS_R1RHO_2SITE:
8339 if r2eff_estimate == 'direct':
8340 self.assertAlmostEqual(value, 1.41359221, 5)
8341 elif r2eff_estimate == 'MC2000':
8342 self.assertAlmostEqual(value, 1.41321968, 5)
8343 elif r2eff_estimate == 'chi2_pyt':
8344 self.assertAlmostEqual(value, 1.36303129, 5)
8345
8346 elif param == 'r2':
8347 if model == MODEL_NOREX:
8348 if r2eff_estimate == 'direct':
8349 self.assertAlmostEqual(value, 11.48392439)
8350 elif r2eff_estimate == 'MC2000':
8351 self.assertAlmostEqual(value, 11.48040934)
8352 elif r2eff_estimate == 'chi2_pyt':
8353 self.assertAlmostEqual(value, 11.47224488)
8354 elif model == MODEL_DPL94:
8355 if r2eff_estimate == 'direct':
8356 self.assertAlmostEqual(value, 10.15688372, 6)
8357 elif r2eff_estimate == 'MC2000':
8358 self.assertAlmostEqual(value, 10.16304887, 6)
8359 elif r2eff_estimate == 'chi2_pyt':
8360 self.assertAlmostEqual(value, 9.20037797, 6)
8361 elif model == MODEL_TP02:
8362 if r2eff_estimate == 'direct':
8363 self.assertAlmostEqual(value, 9.72654896, 6)
8364 elif r2eff_estimate == 'MC2000':
8365 self.assertAlmostEqual(value, 9.72772726, 6)
8366 elif r2eff_estimate == 'chi2_pyt':
8367 self.assertAlmostEqual(value, 9.53948340, 6)
8368 elif model == MODEL_TAP03:
8369 if r2eff_estimate == 'direct':
8370 self.assertAlmostEqual(value, 9.72641887, 6)
8371 elif r2eff_estimate == 'MC2000':
8372 self.assertAlmostEqual(value, 9.72759374, 6)
8373 elif r2eff_estimate == 'chi2_pyt':
8374 self.assertAlmostEqual(value, 9.53926913, 6)
8375 elif model == MODEL_MP05:
8376 if r2eff_estimate == 'direct':
8377 self.assertAlmostEqual(value, 9.72641723, 6)
8378 elif r2eff_estimate == 'MC2000':
8379 self.assertAlmostEqual(value, 9.72759220, 6)
8380 elif r2eff_estimate == 'chi2_pyt':
8381 self.assertAlmostEqual(value, 9.53926778, 6)
8382 elif model == MODEL_NS_R1RHO_2SITE:
8383 if r2eff_estimate == 'direct':
8384 self.assertAlmostEqual(value, 9.34531535, 5)
8385 elif r2eff_estimate == 'MC2000':
8386 self.assertAlmostEqual(value, 9.34602793, 5)
8387 elif r2eff_estimate == 'chi2_pyt':
8388 self.assertAlmostEqual(value, 9.17631409, 5)
8389
8390
8391 else:
8392
8393 value = getattr(cur_spin, param)
8394
8395
8396 print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value))
8397
8398
8399 if spin_id == ':52@N':
8400 if param == 'phi_ex':
8401 if model == MODEL_DPL94:
8402 if r2eff_estimate == 'direct':
8403 self.assertAlmostEqual(value, 0.07599563)
8404 elif r2eff_estimate == 'MC2000':
8405 self.assertAlmostEqual(value, 0.07561937)
8406 elif r2eff_estimate == 'chi2_pyt':
8407 self.assertAlmostEqual(value, 0.12946061)
8408
8409 elif param == 'pA':
8410 if model == MODEL_TP02:
8411 if r2eff_estimate == 'direct':
8412 self.assertAlmostEqual(value, 0.88827040)
8413 elif r2eff_estimate == 'MC2000':
8414 self.assertAlmostEqual(value, 0.88807487)
8415 elif r2eff_estimate == 'chi2_pyt':
8416 self.assertAlmostEqual(value, 0.87746233)
8417 elif model == MODEL_TAP03:
8418 if r2eff_estimate == 'direct':
8419 self.assertAlmostEqual(value, 0.88828922)
8420 elif r2eff_estimate == 'MC2000':
8421 self.assertAlmostEqual(value, 0.88809318)
8422 elif r2eff_estimate == 'chi2_pyt':
8423 self.assertAlmostEqual(value, 0.87747558)
8424 elif model == MODEL_MP05:
8425 if r2eff_estimate == 'direct':
8426 self.assertAlmostEqual(value, 0.88828924, 6)
8427 elif r2eff_estimate == 'MC2000':
8428 self.assertAlmostEqual(value, 0.88809321)
8429 elif r2eff_estimate == 'chi2_pyt':
8430 self.assertAlmostEqual(value, 0.87747562)
8431 elif model == MODEL_NS_R1RHO_2SITE:
8432 if r2eff_estimate == 'direct':
8433 self.assertAlmostEqual(value, 0.94504369, 6)
8434 elif r2eff_estimate == 'MC2000':
8435 self.assertAlmostEqual(value, 0.94496541, 6)
8436 elif r2eff_estimate == 'chi2_pyt':
8437 self.assertAlmostEqual(value, 0.92084707, 6)
8438
8439 elif param == 'dw':
8440 if model == MODEL_TP02:
8441 if r2eff_estimate == 'direct':
8442 self.assertAlmostEqual(value, 1.08875840, 6)
8443 elif r2eff_estimate == 'MC2000':
8444 self.assertAlmostEqual(value, 1.08765638, 6)
8445 elif r2eff_estimate == 'chi2_pyt':
8446 self.assertAlmostEqual(value, 1.09753230, 6)
8447 elif model == MODEL_TAP03:
8448 if r2eff_estimate == 'direct':
8449 self.assertAlmostEqual(value, 1.08837238, 6)
8450 elif r2eff_estimate == 'MC2000':
8451 self.assertAlmostEqual(value, 1.08726698, 6)
8452 elif r2eff_estimate == 'chi2_pyt':
8453 self.assertAlmostEqual(value, 1.09708821, 6)
8454 elif model == MODEL_MP05:
8455 if r2eff_estimate == 'direct':
8456 self.assertAlmostEqual(value, 1.08837241, 6)
8457 elif r2eff_estimate == 'MC2000':
8458 self.assertAlmostEqual(value, 1.08726706, 6)
8459 elif r2eff_estimate == 'chi2_pyt':
8460 self.assertAlmostEqual(value, 1.09708832, 6)
8461 elif model == MODEL_NS_R1RHO_2SITE:
8462 if r2eff_estimate == 'direct':
8463 self.assertAlmostEqual(value, 1.56001812, 5)
8464 elif r2eff_estimate == 'MC2000':
8465 self.assertAlmostEqual(value, 1.55833321, 5)
8466 elif r2eff_estimate == 'chi2_pyt':
8467 self.assertAlmostEqual(value, 1.36406712, 5)
8468
8469 elif param == 'kex':
8470 if model == MODEL_DPL94:
8471 if r2eff_estimate == 'direct':
8472 self.assertAlmostEqual(value/1e5, 4460.43711569/1e5, 7)
8473 elif r2eff_estimate == 'MC2000':
8474 self.assertAlmostEqual(value/1e5, 4419.03917195/1e5, 7)
8475 elif r2eff_estimate == 'chi2_pyt':
8476 self.assertAlmostEqual(value/1e5, 6790.22736344/1e5, 7)
8477 elif model == MODEL_TP02:
8478 if r2eff_estimate == 'direct':
8479 self.assertAlmostEqual(value/1e5, 4921.28602757/1e5, 7)
8480 elif r2eff_estimate == 'MC2000':
8481 self.assertAlmostEqual(value/1e5, 4904.70144883/1e5, 7)
8482 elif r2eff_estimate == 'chi2_pyt':
8483 self.assertAlmostEqual(value/1e5, 5146.20306591/1e5, 7)
8484 elif model == MODEL_TAP03:
8485 if r2eff_estimate == 'direct':
8486 self.assertAlmostEqual(value/1e5, 4926.42963491/1e5, 7)
8487 elif r2eff_estimate == 'MC2000':
8488 self.assertAlmostEqual(value/1e5, 4909.86877150/1e5, 7)
8489 elif r2eff_estimate == 'chi2_pyt':
8490 self.assertAlmostEqual(value/1e5, 5152.51105814/1e5, 7)
8491 elif model == MODEL_MP05:
8492 if r2eff_estimate == 'direct':
8493 self.assertAlmostEqual(value/1e5, 4926.44236315/1e5, 7)
8494 elif r2eff_estimate == 'MC2000':
8495 self.assertAlmostEqual(value/1e5, 4909.88110195/1e5, 7)
8496 elif r2eff_estimate == 'chi2_pyt':
8497 self.assertAlmostEqual(value/1e5, 5152.52097111/1e5, 7)
8498 elif model == MODEL_NS_R1RHO_2SITE:
8499 if r2eff_estimate == 'direct':
8500 self.assertAlmostEqual(value/1e5, 5628.66061488/1e5, 7)
8501 elif r2eff_estimate == 'MC2000':
8502 self.assertAlmostEqual(value/1e5, 5610.20221435/1e5, 6)
8503 elif r2eff_estimate == 'chi2_pyt':
8504 self.assertAlmostEqual(value/1e5, 5643.34067090/1e5, 6)
8505
8506 elif param == 'chi2':
8507 if model == MODEL_NOREX:
8508 if r2eff_estimate == 'direct':
8509 self.assertAlmostEqual(value, 848.42016907, 5)
8510 elif r2eff_estimate == 'MC2000':
8511 self.assertAlmostEqual(value, 3363.95829122, 5)
8512 elif r2eff_estimate == 'chi2_pyt':
8513 self.assertAlmostEqual(value, 5976.49946726, 5)
8514 elif model == MODEL_DPL94:
8515 if r2eff_estimate == 'direct':
8516 self.assertAlmostEqual(value, 179.47041241)
8517 elif r2eff_estimate == 'MC2000':
8518 self.assertAlmostEqual(value, 710.24767560)
8519 elif r2eff_estimate == 'chi2_pyt':
8520 self.assertAlmostEqual(value, 612.72616697, 5)
8521 elif model == MODEL_TP02:
8522 if r2eff_estimate == 'direct':
8523 self.assertAlmostEqual(value, 29.33882530, 6)
8524 elif r2eff_estimate == 'MC2000':
8525 self.assertAlmostEqual(value, 114.47142772, 6)
8526 elif r2eff_estimate == 'chi2_pyt':
8527 self.assertAlmostEqual(value, 250.50838162, 5)
8528 elif model == MODEL_TAP03:
8529 if r2eff_estimate == 'direct':
8530 self.assertAlmostEqual(value, 29.29050673, 6)
8531 elif r2eff_estimate == 'MC2000':
8532 self.assertAlmostEqual(value, 114.27987534)
8533 elif r2eff_estimate == 'chi2_pyt':
8534 self.assertAlmostEqual(value, 250.04050719, 5)
8535 elif model == MODEL_MP05:
8536 if r2eff_estimate == 'direct':
8537 self.assertAlmostEqual(value, 29.29054301, 6)
8538 elif r2eff_estimate == 'MC2000':
8539 self.assertAlmostEqual(value, 114.28002272)
8540 elif r2eff_estimate == 'chi2_pyt':
8541 self.assertAlmostEqual(value, 250.04077478, 5)
8542 elif model == MODEL_NS_R1RHO_2SITE:
8543 if r2eff_estimate == 'direct':
8544 self.assertAlmostEqual(value, 34.44010543, 6)
8545 elif r2eff_estimate == 'MC2000':
8546 self.assertAlmostEqual(value, 134.14368365)
8547 elif r2eff_estimate == 'chi2_pyt':
8548 self.assertAlmostEqual(value, 278.55121388, 5)
8549
8550
8551
8552 model = 'final'
8553 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
8554 print("\nFinal pipe")
8555
8556
8557 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8558
8559 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
8560
8561
8562 print("Optimised model for spin: %s" % (spin_string))
8563 param = 'model'
8564
8565
8566 value = getattr(cur_spin, param)
8567 print("%-10s %-6s %-6s %6s" % ("Parameter:", param, "Value:", value))
8568
8569
8570
8571 file_names = ['r1rho_prime', 'r1']
8572
8573 for file_name_i in file_names:
8574
8575
8576 file_name = "%s.out" % file_name_i
8577
8578
8579 file_path = get_file_path(file_name, result_dir_name + sep + model)
8580
8581
8582 print("Testing file access to: %s"%file_path)
8583 self.assert_(access(file_path, F_OK))
8584
8585
8586 file_prod = open(file_path)
8587 lines_prod = file_prod.readlines()
8588 file_prod.close()
8589
8590
8591 for i, line in enumerate(lines_prod):
8592
8593 line_split = line.split()
8594
8595
8596 if line_split[0] == "#":
8597 print(line),
8598 continue
8599
8600
8601 mol_name, res_num, res_name, spin_num, spin_name, val, sd_error = line_split
8602 print(mol_name, res_num, res_name, spin_num, spin_name, val, sd_error)
8603
8604 if res_num == '52':
8605
8606 self.assertNotEqual(val, 'None')
8607